Qstackedwidget list of used widgets
I am wondering if it is possible to get a list of used widgets (and their names) stocked in a qstackedwidget. Exactly like when you are in QtCreator and you press Ctrl+tab (it shows the list of the last used files and put it in order). If yes, what is the best approach to realise it please?
What you need is QStackedWidget::count() and
Hi (1+1=2), thanks for your reply. I know it's been a while, sorry for it.
But I have another question.
The documentary says that count() "holds the number of widgets contained by this stackedwidget". Sorry but I really don't get it. Does it mean that if I use count() inside a widget it will display the number of widgets my qstackedwidget has? And for widget() it will display me the name of the widget at the given index?!
Please someone could clarify me on those points?!
Well, you quoted the doc yourself: holds the number of widgets contained by this stacked widget, this means that the QStackedWidget knows how many widgets are stacked in it, no matter if you are inside or outside of your widget.
About QStackedWidget::widget, it gives you a pointer on the i-th widget (or zero if there is no such widget)
Hi Johan Solo xD, thanks for your answer. It's clearer now, especially for widget(): I didn't know if it was giving me the name of the widget or the widget itself.
Hi guys, sorry but I have other questions:
the doc mentions that widgets inside the qstackedwidget are part of an internal list and that each one receives an index position. But whenever the current widget changes a signal is emitted. Does it mean that the internal list updates itself and consequently the index position for each widget changes too? And why does this signal needs to be emitted?
I really need clarifications on it please.
No, it does not mean that. It means that the widgets in the stack all have an index, and that only one of those indices is the current (that is: the now visible) widget. The stack is not reordered when another widget becomes the visible one.
Thanks a lot for your reply Andre.
Finally I don't see how count() and widget() can help me there.
Anyway, thanks again.
count() will help you write your iteration loop. Nothing more.
Thanks Andre. I am going to try and have a look at QStandardItemModel then.