PDA

View Full Version : QWidget display on 2 stack widget page



spawnwj
4th September 2006, 10:53
Hi all,

Is it possible to display the same widget on two different page in the stack widget?

For example, my stack widget store different page view 1, 2 and 3.
I want to same widget to appear on page 1 and page 3.

I tried to add the same widget to both page but it will only appear in the later page.

Any hint on this?
:o

Thanks

wysota
4th September 2006, 11:01
Either insert another copy of the page and synchronise them or simply don't call page "3" but call "1" instead. You can achieve this either by changing the argument of the setCurrentIndex slot (if possible) or by subclassing QStackedWidget and reimplementing setCurrentIndex to show page "1" instead of "3" (but I don't advise this). You can also use an additional signal-slot connection (with a custom slot) which will change the page to "1" whenever something changes it to "3" (this might result in a slight flicker though).

spawnwj
4th September 2006, 11:37
Either insert another copy of the page and synchronise them or simply don't call page "3" but call "1" instead. You can achieve this either by changing the argument of the setCurrentIndex slot (if possible) or by subclassing QStackedWidget and reimplementing setCurrentIndex to show page "1" instead of "3" (but I don't advise this). You can also use an additional signal-slot connection (with a custom slot) which will change the page to "1" whenever something changes it to "3" (this might result in a slight flicker though).

Thanks for the reply.

So I guess it is not possible to have the 2 pages pointing to the same widget for display.
Everytime I have to display the page, I have to shift the widget to the display, right?

wysota
4th September 2006, 12:07
Correct. The thing you want is achievable but requires subclassing QStackedWidget or implementing your own stack using QStackedLayout.