QHBoxLayout* hbox = new QHBoxLayout(); hbox->setObjectName("horizontalLayout1");
QHBoxLayout* hbox1 = new QHBoxLayout(); QHBoxLayout* hbox2 = new QHBoxLayout(); hbox1->setObjectName("horizontalLayout1"); hbox2->setObjectName("horizontalLayout2");In this example, two QHBoxLayout objects are created, and their object names are set to "horizontalLayout1" and "horizontalLayout2" respectively. This is useful when there are multiple layouts in a window, and it is necessary to identify them. These examples are using the Qt Library in C++.