#include#include int main() { QHBoxLayout *layout = new QHBoxLayout(); QPushButton *button1 = new QPushButton("Button 1"); QPushButton *button2 = new QPushButton("Button 2"); layout->addWidget(button1); layout->addSpacing(50); layout->addWidget(button2); return 0; }
#includeIn this example, a horizontal layout is created with a label and a line edit widget, and a fixed space of 10 pixels is added between them. This can be used to create forms or other input layouts. Package library: Qt.#include #include int main() { QHBoxLayout *layout = new QHBoxLayout(); QLabel *label = new QLabel("Name:"); QLineEdit *lineEdit = new QLineEdit(); layout->addWidget(label); layout->addSpacing(10); layout->addWidget(lineEdit); return 0; }