QPushButton *button = new QPushButton("Click Me!"); QHBoxLayout *hlayout = new QHBoxLayout; hlayout->insertWidget(0, button);
QLabel *label1 = new QLabel("Username:"); QLabel *label2 = new QLabel("John Doe"); QHBoxLayout *hlayout = new QHBoxLayout; hlayout->addWidget(label1); hlayout->insertWidget(1, label2); // add label2after label1 in the hboxIn this example, two QLabel widgets label1 and label2 are created and added to the QHBoxLayout hlayout. The insertWidget method is used to insert the label2 widget after the first label1 widget. Package Library: Qt5