Это старая версия документа!
QBoxLayout, QVBoxLayout, QHBoxLayout, QGridLayout.
Вертикальная, горизонтальная, так же есть компоновка сеткой.
/*...*/ labComboCapt= new QLabel("Выберите хост", this); comboHostServ= new QComboBox(this); comboHostServ->addItem(QHostAddress(QHostAddress::LocalHost).toString()); QHBoxLayout *layFirstRow= new QHBoxLayout(); layFirstRow->addWidget(labComboCapt); layFirstRow->addWidget(comboHostServ, 1); labEditCapt= new QLabel("Укажите порт", this); editPortServ= new QLineEdit(this); editPortServ->setText("2233"); QHBoxLayout *layDoubleRow= new QHBoxLayout(); layDoubleRow->addWidget(labEditCapt); layDoubleRow->addWidget(editPortServ, 1); labStatus= new QLabel("Здесь будет статус", this); butGetFortune= new QPushButton("Get Fort", this); butQuit= new QPushButton("Quit", this); QHBoxLayout *layButtsRow= new QHBoxLayout(); layButtsRow->addStretch(1); layButtsRow->addWidget(butGetFortune, 1); layButtsRow->addWidget(butQuit, 1); QVBoxLayout *layMain= new QVBoxLayout(this); layMain->addLayout(layFirstRow); layMain->addLayout(layDoubleRow); layMain->addWidget(labStatus, 0, Qt::AlignHCenter); layMain->addLayout(layButtsRow); /*...*/
* При добавлении указываются координаты ячейки и кол-во занимаемых ей строк/столбцов (-1 значит до конца)
/*...*/ labComboCapt= new QLabel("Выберите хост", this); comboHostServ= new QComboBox(this); comboHostServ->addItem(QHostAddress(QHostAddress::LocalHost).toString()); labEditCapt= new QLabel("Укажите порт", this); editPortServ= new QLineEdit(this); editPortServ->setText("2233"); labStatus= new QLabel("Здесь будет статус", this); butGetFortune= new QPushButton("Get Fort", this); butQuit= new QPushButton("Quit", this); QGridLayout *layMainGrid= new QGridLayout(this); layMainGrid->addWidget(labComboCapt, 0, 0); layMainGrid->addWidget(comboHostServ, 0, 1, 1, -1); layMainGrid->addWidget(labEditCapt, 1, 0); layMainGrid->addWidget(editPortServ, 1, 1, 1, -1); layMainGrid->addWidget(labStatus, 2, 0, 1, -1, Qt::AlignCenter); layMainGrid->addWidget(butGetFortune, 3, 1); layMainGrid->addWidget(butQuit, 3, 2); layMainGrid->setColumnStretch(1, 1); layMainGrid->setColumnStretch(2, 1); /*...*/