PDA

View Full Version : Sharing the same widget object between several tabs



Lipton
12th April 2010, 19:39
Hi all,

I'm building a UI with a tab widget that has (obviously) several tabs. On the top tab, I have some widget objects that I would also like to show on the other tabs. Now whenever I copy a widget from one tab and copying it on the other, Qt Designer generates a new object(name) for it. However, I want the exact same instance to appear on all tabs. I guess there is an easy answer to this, as it seems to be a fundamental question.
How do you do this?

Thanks!

wysota
13th April 2010, 01:21
I guess there is an easy answer to this, as it seems to be a fundamental question.
Yes, there is a very easy answer to this. And the answer is "you can't do that".

You have to create multiple instances of the widget you want to "share" and synchronize them (i.e. using signals and slots). It is technically possible to "reuse" the same widget instance but trust me, you don't want to do that.

nish
13th April 2010, 05:16
You have to do it in code, I am not too sure that Designer can handle it. As the tabchanged just move the common widget to the layout of the current tab.

Lipton
23rd April 2010, 23:39
Thank you for the hints!

SixDegrees
24th April 2010, 15:21
Another approach, which may or may not work depending on your layout and where your repeated widget is displayed, would be to put the constant widget alongside, above or below the tab stack, so it is simply always visible, while users can flip through the varying tabs as needed.