//左边列表选项与右边窗体关联
QListWidget *list =new QListWidget(this);
list->insertItem(0,tr("Window1"));
list->insertItem(1,tr("Window2"));
QLabel *label1 =new QLabel(tr("WindowTest1"));
QLabel *label2 =new QLabel(tr("WindowTest2"));
QStackedWidget *stack =new QStackedWidget(this);
stack->addWidget(label1);
stack->addWidget(label2);
QHBoxLayout *mainLayout =new QHBoxLayout(this);
mainLayout->setMargin(5);
mainLayout->setSpacing(5);
mainLayout->addWidget(list);
mainLayout->addWidget(stack,0,Qt::AlignHCenter);
//设置左侧list所占的宽度
mainLayout->setStretchFactor(list,1);
mainLayout->setStretchFactor(stack,3);
connect(list,SIGNAL(currentRowChanged(int)),stack,SLOT(setCurrentIndex(int)));
效果图: