QHBoxLayout* layout = new QHBoxLayout(); QLabel* label1 = new QLabel("Label 1"); QLabel* label2 = new QLabel("Label 2"); layout->addWidget(label1); layout->addWidget(label2); setLayout(layout);
QHBoxLayout* layout1 = new QHBoxLayout(); QHBoxLayout* layout2 = new QHBoxLayout(); QLabel* label1 = new QLabel("Label 1"); QLabel* label2 = new QLabel("Label 2"); QLabel* label3 = new QLabel("Label 3"); layout1->addWidget(label1); layout1->addLayout(layout2); layout2->addWidget(label2); layout2->addWidget(label3); setLayout(layout1);This code creates two QHBoxLayouts, adds two QLabel widgets to the first layout and adds the second layout to the first layout, which contains two more QLabel widgets. The QHBoxLayout class is part of the Qt Core module, which is part of the Qt framework.