분홍색 상자를 QHBoxLayout으로 만드는 것이 좋습니다 (단지 레이아웃이 아닌). 그 이유는 QLayouts가 고정 크기를 만드는 기능을 제공하지 않지만 QWidgets은 기능을 제공하기 때문입니다.
// first create the four widgets at the top left,
// and use QWidget::setFixedWidth() on each of them.
// then set up the top widget (composed of the four smaller widgets):
QWidget *topWidget = new QWidget;
QHBoxLayout *topWidgetLayout = new QHBoxLayout(topWidget);
topWidgetLayout->addWidget(widget1);
topWidgetLayout->addWidget(widget2);
topWidgetLayout->addWidget(widget3);
topWidgetLayout->addWidget(widget4);
topWidgetLayout->addStretch(1); // add the stretch
topWidget->setFixedHeight(50);
// now put the bottom (centered) widget into its own QHBoxLayout
QHBoxLayout *hLayout = new QHBoxLayout;
hLayout->addStretch(1);
hLayout->addWidget(bottomWidget);
hLayout->addStretch(1);
bottomWidget->setFixedSize(QSize(50, 50));
// now use a QVBoxLayout to lay everything out
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(topWidget);
mainLayout->addStretch(1);
mainLayout->addLayout(hLayout);
mainLayout->addStretch(1);
당신이 정말로 두 개의 별도의 레이아웃을 갖고 싶어 - 분홍색 상자 하나와 파란색 상자 하나 - 아이디어는, 기본적으로 자신의 QVBoxLayout에 파란색 상자를 만들 거라고 제외하고는 동일합니다 다음을 사용하십시오 :
mainLayout->addWidget(topWidget);
mainLayout->addLayout(bottomLayout);