Results 1 to 3 of 3

Thread: replace widget in Qsplitter

  1. #1
    Join Date
    May 2015
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default replace widget in Qsplitter

    hi guys,

    i have problem.. when i have 2 widgets(buttons) in the same splliter and i want to replace the first one with Tabwidget.. i lose the right stretch factor (1:1) it will be like (2:1) i use insertwidget(0,tab)

    Qt Code:
    1. splitter->addwidget(qbut1);
    2. splitter->addwidget(qbut2);
    3. splitter->insertwidget(0,tab);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: replace widget in Qsplitter

    If the intent is to switch back and forth between displaying a button or a table in the left pane then you would be better off putting those in a QStackedWidget and adding that as the first widget in the splitter.

    If you stick with your current approach then you can remove the button widget by simply deleting the object. If you want to control the stretch factors then do so after you have added/removed.

  3. #3
    Join Date
    May 2015
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: replace widget in Qsplitter

    the problem is even when i add at the first one tab and one button..tab takes size more than button
    how can i make it (1:1) i try
    Qt Code:
    1. splitter->setStretchFactor(0,1);
    2. splitter->setStretchFactor(1,1);
    To copy to clipboard, switch view to plain text mode 

    but it doesn't work

Similar Threads

  1. Widget proportions in QSplitter
    By godi in forum Qt Programming
    Replies: 4
    Last Post: 30th September 2011, 08:59
  2. replace a widget in QVBoxLayout
    By migel in forum Newbie
    Replies: 4
    Last Post: 31st May 2011, 21:01
  3. Replace widget on tab
    By wirasto in forum Qt Programming
    Replies: 1
    Last Post: 14th August 2010, 14:01
  4. How do I replace a widget?
    By pir in forum Qt Programming
    Replies: 4
    Last Post: 24th July 2006, 16:51

Tags for this Thread

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.