QGridLayout

The QGridLayout is used to arrange widgets by specifying the number of rows and columns that will be filled up by multiple widgets. A grid-like structure mimics a table in that it has rows and columns and widgets are inserted as cells where a row and column meet.

Create a new folder and, using of any editor, create a file named main.cpp:

#include <QApplication>#include <QPushButton>#include <QGridLayout>#include <QLineEdit>#include <QDateTimeEdit>#include <QSpinBox>#include <QComboBox>#include <QLabel>#include <QStringList>int main(int argc, char *argv[]){   QApplication app(argc, argv);   QWidget *window = new QWidget;   QLabel *nameLabel = new QLabel("Open Happiness");   QLineEdit *firstNameLineEdit= new QLineEdit; QLineEdit *lastNameLineEdit= ...

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.