Qt Cheat Sheet

By Module: QtGUI - QtWidgets


Base Classes

QApplication

Ref: C++ - PySide

The QApplication class manages the GUI application's control flow and main settings.

QApplication specializes QGuiApplication with some functionality needed for QWidget-based applications. It handles widget specific initialization, finalization.

QMainWindow

Ref: C++ - PySide

mainwindowlayout

The QMainWindow class provides a main application window.

A main window provides a framework for building an application's user interface. Qt has QMainWindow and its related classes for main window management. QMainWindow has its own layout to which you can add QToolBars, QDockWidgets, a QMenuBar, and a QStatusBar. The layout has a center area that can be occupied by any kind of widget.

QWidget

Ref: C++ - PySide

The QWidget class is the base class of all user interface objects.

The widget is the atom of the user interface: it receives mouse, keyboard and other events from the window system, and paints a representation of itself on the screen. Every widget is rectangular, and they are sorted in a Z-order. A widget is clipped by its parent and by the widgets in front of it.

A widget that is not embedded in a parent widget is called a window. Usually, windows have a frame and a title bar, although it is also possible to create windows without such decoration using suitable window flags). In Qt, QMainWindow and the various subclasses of QDialog are the most common window types.


UI Layouts

The layouts define the way widgets are layed out on the canvas.

QFormLayout

Ref: C++ - PySide

qformlayout-win

The QFormLayout class manages forms of input widgets and their associated labels.

QFormLayout is a convenience layout class that lays out its children in a two-column form. The left column consists of labels and the right column consists of "field" widgets (line editors, spin boxes, etc.).


QGridLayout

Ref: C++ - PySide

QGridLayout-1

The QGridLayout class lays out widgets in a grid.


QHBoxLayout

Ref: C++ - PySide

qhboxlayout-with-5-children

The QHBoxLayout class lines up widgets horizontally.

This class is used to construct horizontal box layout objects. See QBoxLayout for details.


QStackedLayout

Ref: C++ - PySide

QStackedLayout-1

The QStackedLayout class provides a stack of widgets where only one widget is visible at a time.

QStackedLayout can be used to create a user interface similar to the one provided by QTabWidget. There is also a convenience QStackedWidgetclass built on top of QStackedLayout.


QTabWidget

Ref: C++ - PySide

windows-tabwidget

The QTabWidget class provides a stack of tabbed widgets.


QVBoxLayout

Ref: C++ - PySide

qvboxlayout-with-5-children

The QVBoxLayout class lines up widgets vertically.

This class is used to construct vertical box layout objects. See QBoxLayout for details.

UI Widgets

Widgets are all derived by baseclass QWidget.

Most common Qt widgets

QLabel QComboBox QCheckBox QRadioButton QPushButton QTableWidget QLineEdit QSlider QProgressBar

QWidget

Ref: C++ - PySide

The QWidget class is the base class of all user interface objects.

Often used properties/methods:

QCheckBox

Ref: C++ - PySide

windows-checkbox

A QCheckBox is an option button that can be switched on (checked) or off (unchecked). Checkboxes are typically used to represent features in an application that can be enabled or disabled without affecting others. Different types of behavior can be implemented. For example, a QButtonGroup can be used to group check buttons logically, allowing exclusive checkboxes. However, QButtonGroup does not provide any visual representation.

QCheckBox => QAbstractButton => QWidget => QObject


QComboBox

Ref: C++ - PySide

QComboBox

A QComboBox provides a means of presenting a list of options to the user in a way that takes up the minimum amount of screen space.

A combobox is a selection widget that displays the current item, and can pop up a list of selectable items. A combobox may be editable, allowing the user to modify each item in the list.


QFrame

Ref: C++

QFrame

The QFrame class is the base class of widgets that can have a frame.

QMenu uses this to "raise" the menu above the surrounding screen. QProgressBar has a "sunken" look. QLabel has a flat look. The frames of widgets like these can be changed.


QLabel

Ref: C++ - PySide

windows-label

QLabel is used for displaying text or an image. No user interaction functionality is provided. The visual appearance of the label can be configured in various ways, and it can be used for specifying a focus mnemonic key for another widget.


QLineEdit

Ref: C++ - PySide

QLineEdit

A line edit allows the user to enter and edit a single line of plain text with a useful collection of editing functions, including undo and redo, cut and paste, and drag and drop (see setDragEnabled()).


QListWidget

Ref: C++ - PySide

windows-listview

The QListWidget class provides an item-based list widget.


QProgressBar

Ref: C++

The QProgressBar widget provides a horizontal or vertical progress bar.


QPushButton

Ref: C++ - PySide

plastique-pushbutton

The QPushButton widget provides a command button.


QRadioButton

Ref: C++ - PySide

windows-radiobutton

The QRadioButton widget provides a radio button with a text label.


QSlider

Ref: C++

windows-slider

The QSlider widget provides a vertical or horizontal slider.


QSplitter

Ref: C++ PySide

QSplitter

The QSplitter class implements a splitter widget.

A splitter lets the user control the size of child widgets by dragging the boundary between them. Any number of widgets may be controlled by a single splitter. The typical use of a QSplitter is to create several widgets and add them using insertWidget() or addWidget().


QTableWidget

Ref: C++ - PySide

windows-tableview

The QTableWidget class provides an item-based table view with a default model.

Table widgets provide standard table display facilities for applications. The items in a QTableWidget are provided by QTableWidgetItem.


QTreeView

Ref: C++ PySide

(Model/View)

windows-treeview

The QTreeView class provides a default model/view implementation of a tree view.

A QTreeView implements a tree representation of items from a model. This class is used to provide standard hierarchical lists that were previously provided by the QListView class, but using the more flexible approach provided by Qt's model/view architecture.

QTreeView implements the interfaces defined by the QAbstractItemView class to allow it to display data provided by models derived from the QAbstractItemModel class.


QTreeWidget

Ref: C++ - PySide

windows-treeview

The QTreeWidget class provides a tree view that uses a predefined tree model.

The QTreeWidget class is a convenience class that provides a standard tree widget with a classic item-based interface similar to that used by the QListView class in Qt 3. This class is based on Qt's Model/View architecture and uses a default model to hold items, each of which is a QTreeWidgetItem.


Misc. Classes

QBasicTimer

Ref: C++

The QBasicTimer class provides timer events for objects.

QSize

Ref: C++ - PySide

The QSize class defines the size of a two-dimensional object using integer point precision.


Misc

Qt Stylesheet Reference: A list of various information about Stylesheets