#include#include #include // create a QVBoxLayout QVBoxLayout* layout = new QVBoxLayout(); // create some widgets QPushButton* button = new QPushButton("Click me"); QLabel* label = new QLabel("Hello World"); // add widgets to the layout layout->addWidget(button); layout->addWidget(label);
#includeIn this example, we create a QVBoxLayout and a QHBoxLayout. We add two QPushButtons to the QHBoxLayout, and then add the QHBoxLayout and a QLabel to the QVBoxLayout. This creates a nested layout, which is a common layout technique. These examples use the Qt library, which is a C++ toolkit for developing cross-platform applications. It provides a range of GUI features, including widgets, layouts, and event handling. The QVBoxLayout class is part of the Qt Core module, which is one of many modules in the Qt library.#include #include #include // create a QVBoxLayout QVBoxLayout* layout = new QVBoxLayout(); // create a QHBoxLayout QHBoxLayout* subLayout = new QHBoxLayout(); // create some widgets QPushButton* button1 = new QPushButton("Click me"); QPushButton* button2 = new QPushButton("Don't click me"); QLabel* label = new QLabel("Hello World"); // add buttons to the sub-layout subLayout->addWidget(button1); subLayout->addWidget(button2); // add sub-layout and label to the main layout layout->addLayout(subLayout); layout->addWidget(label);