May 2019
Intermediate to advanced
542 pages
13h 37m
English
QWidget is the parent class of all other widgets, so any properties and methods it has will also be available in any other widget. By itself, a QWidget object can be useful as a container for other widgets, a filler to fill blank areas, or as a base class for top-level windows.
Creating a widget is as simple as this:
# inside MainWindow.__init__() subwidget = qtw.QWidget(self)
Notice we've passed self as an argument. If we're creating a widget to be placed on or used inside another widget class, as we are here, it's a good idea to pass a reference to the parent widget as the first argument. Specifying a parent widget will ensure that the child widget is destroyed and cleaned up when the parent is, and limit its visibility to inside ...
Read now
Unlock full access