PDA

View Full Version : Display one widget at a time



stbb24
8th June 2012, 04:02
I have a menu option and under it is extract and embedd.
This is the default interface (which is the embedd interface)
7816

Now when the user clicks on the extract option a different window should apper. Like the one below
7817

And when the user switches back to the embedd option the interface should look like the first image

Any suggestions???

ChrisW67
8th June 2012, 06:02
QStackedWidget

stbb24
8th June 2012, 13:28
can you give a simple sample?

sonulohani
8th June 2012, 13:36
Read Documentation---->




QWidget *firstPageWidget = new QWidget;
QWidget *secondPageWidget = new QWidget;
QWidget *thirdPageWidget = new QWidget;

QStackedWidget *stackedWidget = new QStackedWidget;
stackedWidget->addWidget(firstPageWidget);
stackedWidget->addWidget(secondPageWidget);
stackedWidget->addWidget(thirdPageWidget);

QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(stackedWidget);
setLayout(layout);


QStackedWidget provides no intrinsic means for the user to switch page. This is typically done through a QComboBox or a QListWidget that stores the titles of the QStackedWidget's pages. For example:


QComboBox *pageComboBox = new QComboBox;
pageComboBox->addItem(tr("Page 1"));
pageComboBox->addItem(tr("Page 2"));
pageComboBox->addItem(tr("Page 3"));
connect(pageComboBox, SIGNAL(activated(int)),
stackedWidget, SLOT(setCurrentIndex(int)));

wysota
8th June 2012, 21:33
can you give a simple sample?

Things marked green on this forum are hyperlinks, most often to Qt documentation. If you click such link, you'll be redirected to aforementioned documentation. Once you do that, you'll learn that Qt class manuals contain embedded examples or links to external examples of using the class being documented.