Managing layouts
Qt provides a set of convenient layout management classes to automatically arrange child widgets within another widget to ensure that the UI remains usable. The QLayout
class is the base class of all layout managers. You can also create your own layout manager by reimplementing the setGeometry()
, sizeHint()
, addItem()
, itemAt()
, takeAt()
, and minimumSize()
functions. Please note that once the layout manager is deleted, the layout management will also stop.
The following list provides a brief description of the major layout classes:
QVBoxLayout
lines up widgets vertically.QHBoxLayout
lines up widgets horizontally.QGridLayout
lays widgets out in a grid.QFormLayout
manages forms of input widgets and their associated labels.QStackedLayout
provides a stack of widgets where only one widget is visible at a time.
QLayout
uses multiple inheritances by inheriting from QObject
and QLayoutItem
. The subclasses of QLayout
are QBoxLayout
, QGridLayout...