PDA

View Full Version : [QTabWidget] Removes all the pages and delete them



qt_developer
11th April 2013, 15:21
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:



while(ui.tabWidget->count())
{
delete ui.tabWidget->widget(ui.tabWidget->currentIndex());
}


There are another better implementation?

Kind regards!

Urthas
17th April 2013, 06:06
void QTabWidget::removeTab( int index )

ChrisW67
17th April 2013, 07:17
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.

Urthas
17th April 2013, 17:54
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. :)

jml
17th August 2013, 01:18
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.