
Application Development with Qt Creator - Second Edition

Qt Widgets includes a robust layout system to control the presentation of widgets on the display. In Qt Creator Designer, you can pick from the following layouts:
QBoxLayout
: This lays out its view children horizontally or vertically
QHBoxLayout
: This lays out its view children horizontally
QVBoxLayout
: This lays out its view children vertically
QFormLayout
: This lays out pairs of widgets (such as labels and textboxes) side by side and then tiles those pairs vertically, giving the appearance of a form
QGridLayout
: This lays out widgets in a grid
QStackedLayout
: This shows only a single widget at a time
Using one of these layouts is easy: simply choose the appropriate layout in Qt Creator Designer and drag it to the widget or window you're building. If you're constructing a hierarchy of widgets in the code, you add the widgets to the layout and set the parent widget's layout, like this:
QWidget *window = new QWidget(); QPushButton *button1 = new QPushButton...