1. Stack form qstackedwidget:
(1) initialize the ListBox qlistwidget:
QListWidget *list=new QListWidget (this);
list->insertItem(0,tr("Window1"));
list->insertItem(1,tr("Window2"));
list->insertItem(2,tr("Window3"));
(2) create a stack form qstackedwidget:
QStackedWidget *stack=new QStackedWidget(this);
stack->addWidget(label1);
stack->addWidget(label2);
stack->addWidget(label3);
(3) Insert the tag control into the stack form:
QLabel *label1=new QLabel(tr("SHOW1"));
QLabel *label2=new QLabel(tr("SHOW2"));
QLabel *label3=new QLabel(tr("SHOW3"));
(4) layout the dialog box:
QHBoxLayout *mainLayout =new QHBoxLayout(this);
mainLayout->setMargin(6);
mainLayout->setSpacing(6);
mainLayout->addWidget(list);
mainLayout->addWidget(stack,0,Qt::AlignHCenter);
mainLayout->setStretchFactor(list,1);
mainLayout->setStretchFactor(stack,1);
(5) connect the qlistwidget signal with the slot function of the stack form:
connect(list,SIGNAL(currentRowChanged(int)),stack,SLOT(setcurrentIndex(int)));
Qt5 layout management (2)