Results 1 to 3 of 3

Thread: QTabWidget remove a page at the page's request

  1. #1
    Join Date
    Nov 2006
    Posts
    86
    Thanks
    6
    Thanked 14 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QTabWidget remove a page at the page's request

    I'm not quite sure where to go here. I have a QTabWidget that contains a page. Now the page will emit a signal when it wants the tab that it resides in to close. Right now when the page emits its signal, the slot that recieves it is in the QTabWidget, and its calling QTabWidget->remove() and then tries to delete the pointer to the page.

    Well, the pointer is deleted ok, but the problem is that since the signal was emitted from a widget that existed down in the page, it now doesn't exist anymore, so when the stack returns back right after the signal was emitted, it now tries to run code in an object that was deleted so it ends up crapping out.

    Any suggestions? I could use them

    Paul

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTabWidget remove a page at the page's request

    Call page->deleteLater() in the slot. This way the page widget will be deleted once the event loop gains control.

  3. The following 3 users say thank you to marcel for this useful post:

    arturo182 (2nd September 2009), CoderMan (27th February 2012), thomaspu (29th December 2007)

  4. #3
    Join Date
    Nov 2006
    Posts
    86
    Thanks
    6
    Thanked 14 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTabWidget remove a page at the page's request

    Dude, you are my hero!

    Paul

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.