#include#include QPushButton *button = new QPushButton("Click me"); QHBoxLayout *layout = new QHBoxLayout(); layout->addWidget(button);
#includeThis example adds multiple widgets, including QPushButton and QLabel, to a QVBoxLayout using the addWidget() function of the QVBoxLayout class. Package library: Qt Libraries#include #include QPushButton *button1 = new QPushButton("OK"); QPushButton *button2 = new QPushButton("Cancel"); QLabel *label = new QLabel("Enter your name:"); QVBoxLayout *layout = new QVBoxLayout(); layout->addWidget(label); layout->addWidget(button1); layout->addWidget(button2);