Running and showing a certain page on stacked widget as default
-
Hey guys,
I'm trying to run an application with stacked widget.
Is there a way to view a default page in the stacked widget? -
@georgehanna1993
Just useQStackedWidget::setCurrentIndex/Widget()
to set whichever page/widget you want before showing. Yes, you have to have the "default page" among its pages. -
@georgehanna1993 said in Running and showing a certain page on stacked widget as default:
@JonB tried that, didn't work
In what way "didn't work"? It sets the specified page as the current one displayed.
is there any way to set an index for each page
Pages are indexed (from 0 upward) in the order you add them via
QStackedWidget::addWidget()
, or you can alter the order viaQStackedWidget::insertWidget()
. You can pass an index number tosetCurrentIndex()
, or you can pass the actual desired widget viasetCurrentWidget()
.How should it look like?
How should what look? The
QStackedWidget
will display whichever the previously-specified current index/widget is.QStackedWidget
works fine. I do not know what your expectations might be. -
Inside the code itself, I found that the QT Designer automatically assigned page number 3 to be the current Index, I changed it and it worked, Thanks!
-
@georgehanna1993
It probably just saves with whatever the last page you created, or edited, as the current one.