Results 1 to 5 of 5

Thread: Sharing the same widget object between several tabs

  1. #1
    Join Date
    Feb 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Sharing the same widget object between several tabs

    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!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Sharing the same widget object between several tabs

    Quote Originally Posted by Lipton View Post
    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.

  3. #3
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Sharing the same widget object between several tabs

    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.

  4. #4
    Join Date
    Feb 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Sharing the same widget object between several tabs

    Thank you for the hints!

  5. #5
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Sharing the same widget object between several tabs

    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.

Similar Threads

  1. Replies: 5
    Last Post: 12th February 2010, 07:09
  2. Replies: 7
    Last Post: 26th November 2009, 14:29
  3. Replies: 4
    Last Post: 17th October 2009, 22:31
  4. Creating a QAccessibleWidget object for widget
    By Rakesh_Kumar in forum Qt Programming
    Replies: 0
    Last Post: 27th January 2009, 08:13
  5. Sharing same widget between 2 wizards
    By Equilibrium in forum Qt Programming
    Replies: 3
    Last Post: 11th September 2006, 10:27

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.