Overview
In this API Reference we will cover relevant classes and functions which are part of the QtWidgets
module. The QtWidgets
module contains classes that provide a set of UI elements to create classic desktop-style graphical user interfaces (GUI's). The QWidget
class is the base class for all UI objects, and the QLayout
class is the base class for all layout objects. An overview of the classes and functions in the QtWidgets
module is provided at the bottom of this page.
Note
Methods from parent classes (i.e. QWidget
and QLayout
) are not repeated in the reference of each subclass. However, as always in Python ( ), these methods are applicable to all subclasses.
Note
Note the difference between QtWidgets
and QWidget
, which are a module and class respectively. Convince yourself by examining the following code:
from PySide6 import QtWidgets
from PySide6.QtWidgets import QWidget
# The following two lines are equivalent:
widget = QtWidgets.QWidget()
widget = QWidget()
QWidget
in two ways. In practice we do not use direct instances of QWidget
to build our GUI, but rather use its subclasses (see the list below).
All classes from the QtWidgets
module:
QApplication
: Manages the GUI application's control flow and main settings.QLayout
: Base class of all layout objects inQtWidgets
.-
QWidget
: Base class of all widget objects inQtWidgets
. -
Subclasses derived from
QLayout
:QHBoxLayout
: Manages a horizontal layout of widgets.QVBoxLayout
: Manages a vertical layout of widgets.QGridLayout
: Manages a grid layout where space is divided up into rows and columns.QFormLayout
: Manages a layout where space is divided in a left column with labels and right column with widgets.
-
Subclasses derived from
QWidget
:QMainWindow
: Provides a framework for building an application's user interface.QGroupBox
: Provides a frame, a title on top, and can display various other widgets inside itself.QTextEdit
: Displays text and allows the user to edit it.QLineEdit
: A widget that allows the user to enter and edit a single line of plain text.QFileDialog
: Provides a dialog that allows the user to select files or directories.QCheckBox
: Toggle button with a checkbox indicator.QLabel
: A widget that displays text.QComboBox
: A widget that allows the user to choose from a list of options.QSpinBox
: A widget that allows the user to choose a number from a range.QDoubleSpinBox
: A widget that allows the user to choose a floating-point number from a range.QPushButton
: A push button that can be clicked by the user.