#includeIn this example, we create a QHBoxLayout and add three widgets to it (a QLabel, a QSpinBox, and a QPushButton). We then use the setStretch() function to set the stretch factor for each widget. The first widget (the label) has a stretch factor of 1, meaning it will take up 1/4 of the available space. The second widget (the spin box) has a stretch factor of 2, meaning it will take up 1/2 of the available space. The third widget (the button) has a stretch factor of 1, meaning it will take up the remaining 1/4 of the available space. This code example uses the Qt library.int main(int argc, char *argv[]) { QApplication a(argc, argv); // Create widgets QLabel *label = new QLabel("Label"); QSpinBox *spinBox = new QSpinBox(); QPushButton *button = new QPushButton("Button"); // Create QHBoxLayout QHBoxLayout *layout = new QHBoxLayout(); layout->addWidget(label); layout->addWidget(spinBox); layout->addWidget(button); // Set stretch factors layout->setStretch(0, 1); layout->setStretch(1, 2); layout->setStretch(2, 1); // Create main window QWidget *window = new QWidget(); window->setLayout(layout); window->show(); return a.exec(); }