Skip to content

read the docs Qt crash course example broken #2129

@texadactyl

Description

@texadactyl

FWIW, a fix that works on 2021-12-01 with these Pythonic Qt modules:

PyQt5                              5.12.3
PyQt5-sip                          12.9.0
pyqtgraph                          0.12.3
PyQtWebEngine                      5.12.1
QtAwesome                          1.0.2
qtconsole                          5.2.1
QtPy                               1.10.0

The new Qt crash course example source code:

import sys
from PyQt5 import QtGui, QtWidgets  # (the example applies equally well to PySide2)
import pyqtgraph as pg

## Always start by initializing Qt (only once per application)
app = QtWidgets.QApplication(sys.argv)

## Define a top-level widget to hold everything
w = QtWidgets.QWidget()

## Create some widgets to be placed inside
btn = QtWidgets.QPushButton('press me')
text = QtWidgets.QLineEdit('enter text')
listw = QtWidgets.QListWidget()
plot = pg.PlotWidget()

## Create a grid layout to manage the widgets size and position
layout = QtWidgets.QGridLayout()
w.setLayout(layout)

## Add widgets to the layout in their proper positions
layout.addWidget(btn, 0, 0)   # button goes in upper-left
layout.addWidget(text, 1, 0)   # text edit goes in middle-left
layout.addWidget(listw, 2, 0)  # list widget goes in bottom-left
layout.addWidget(plot, 0, 1, 3, 1)  # plot goes on right side, spanning 3 rows

## Display the widget as a new window
w.show()

## Start the Qt event loop
app.exec_()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions