Results 1 to 5 of 5

Thread: [QTabWidget] Removes all the pages and delete them

  1. #1
    Join Date
    May 2012
    Posts
    99
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question [QTabWidget] Removes all the pages and delete them

    Hi all,

    I haven't found a method to remove and delete the tabs for a QTabWidget into QTabWidget class.

    I used this code to remove and delete the tabs for a QTabWidget:

    Qt Code:
    1. while(ui.tabWidget->count())
    2. {
    3. delete ui.tabWidget->widget(ui.tabWidget->currentIndex());
    4. }
    To copy to clipboard, switch view to plain text mode 

    There are another better implementation?

    Kind regards!

  2. #2
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Thanks
    7
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default Re: [QTabWidget] Removes all the pages and delete them

    void QTabWidget::removeTab( int index )

  3. #3
    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: [QTabWidget] Removes all the pages and delete them

    That does not delete the tab widget and in the OP's case would be the equivalent of calling clear(). Deleting the widget directly has the desired effect although I'd typically delete widget zero until the list was empty.

  4. #4
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Thanks
    7
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default Re: [QTabWidget] Removes all the pages and delete them

    Yes, I know. The OP said he couldn't find anything about removing and deleting, though he had deletion covered. I was simply chipping in with removal, proper.

  5. #5
    Join Date
    Dec 2006
    Posts
    33
    Thanks
    10
    Thanked 5 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: [QTabWidget] Removes all the pages and delete them

    I'm having a problem where I call QTabWidget::clear(), but then when I try to delete the widgets that I inserted as tab pages, it crashes. The documentation says that the clear() member does not delete the widgets, but I'm beginning to think otherwise.
    Jim L
    Seattle, WA

Similar Threads

  1. Replies: 6
    Last Post: 21st August 2013, 12:53
  2. Replies: 6
    Last Post: 20th October 2010, 15:17
  3. Replies: 2
    Last Post: 27th October 2009, 13:40
  4. Qtabwidget: same widgets across all pages
    By ike in forum Qt Programming
    Replies: 1
    Last Post: 1st October 2009, 14:30
  5. Replies: 4
    Last Post: 19th February 2009, 11:10

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.