PDA

View Full Version : QTabWidget remove a page at the page's request



thomaspu
29th December 2007, 05:04
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 :o

Paul

marcel
29th December 2007, 08:25
Call page->deleteLater() in the slot. This way the page widget will be deleted once the event loop gains control.

thomaspu
29th December 2007, 20:45
Dude, you are my hero!

Paul