QVBoxLayout

In a QVBoxLayout layout, widgets are aligned vertically and they are packed in the layout from top to bottom.

Consider the following diagram:

For QVBoxLayout, the arrow gives the direction of growth in which the widgets are added to the layout. The first widget, widget 1, will occupy the top of the layout, while the last call to addWidget() will make widget 5 occupy the bottom of the layout.

To illustrate how to use the QVBoxLayout, consider the following program:

#include <QApplication>#include <QVBoxLayout>#include <QPushButton>#include <QLabel>#include <QLineEdit>int main(int argc, char *argv[]){ QApplication app(argc, argv); ...

Get Getting Started with Qt 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.