Results 1 to 6 of 6

Thread: QTabWidget delete order

  1. #1
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default QTabWidget delete order

    Hi,
    Does a QTabWidget remove the tab from the last to the first when it's deleted ?
    The only way to remove one tab at the end is to use an event to know when it's closed and close all other ?
    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTabWidget delete order

    Quote Originally Posted by Alundra View Post
    Does a QTabWidget remove the tab from the last to the first when it's deleted ?
    From the code it looks like the internal stack widget deletes the widgets on destruction, in the order of the stack/tabs.
    But that should be easy enough to test, right

    Quote Originally Posted by Alundra View Post
    The only way to remove one tab at the end is to use an event to know when it's closed and close all other ?
    Not sure what you mean.
    To remove the last tab, you call removeTab() with the last index, which is count() - 1.

    Cheers,
    _

  3. #3
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTabWidget delete order

    I mean for example remove all other tab and the index 1 at the end, no way to set one tab which will be removed after all other ?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTabWidget delete order

    I am still not sure what you mean.

    if you want to remove alll but one tab, you could get that tab's widget, remove that tab, then clear the tab widget and re-add the one tab.

    Or with two loops
    Qt Code:
    1. // remove all tabs before the one to keep
    2. for (int = 0; i < indexToKeep; ++i) {
    3. tabWidget->removeTab(0);
    4. }
    5. // remove all tabs after the one to keep
    6. while (tabWidget->count() > 1) {
    7. tabWidget->removeTab(1);
    8. }
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  5. #5
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTabWidget delete order

    I have one window which contains multiple window, it's a tabbed window I made, but all other tab depend of one tab and if this tab is removed all other has to be removed before.
    Actually tabs are not movable because when I drag out one tab to make it floatable I got an assert, looks like a bug from Qt, but not sure.
    So, actually the main tab is always the first so it's not a problem but if a day tab can be movable, the main tab could not be first.
    Other way is to make this tab not movable and all other movable possible if Qt allows.
    I will surely post the issue which cause an assert but it's not the topic here...

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTabWidget delete order

    QTabBar has a signal for when tabs are moved so you should be able to keep the index of the "first tab" updated.

    Or you just keep a pointer to that tab's widget and query its current index with QTabWidget::indexOf() before starting removing.

    Cheers,
    _

Similar Threads

  1. [QTabWidget] Removes all the pages and delete them
    By qt_developer in forum Newbie
    Replies: 4
    Last Post: 17th August 2013, 02:18
  2. Replies: 3
    Last Post: 28th September 2012, 15:01
  3. Replies: 0
    Last Post: 9th August 2012, 19:27
  4. tab order in QTabWidget
    By ugluk in forum Qt Programming
    Replies: 2
    Last Post: 23rd July 2012, 14:25
  5. Replies: 4
    Last Post: 5th December 2009, 11:33

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.