[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:
Code:
while(ui.tabWidget->count())
{
delete ui.tabWidget->widget(ui.tabWidget->currentIndex());
}
There are another better implementation?
Kind regards!
Re: [QTabWidget] Removes all the pages and delete them
void QTabWidget::removeTab( int index )
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.
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. :)
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.