Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions
Problem in clearing the tab from tabwidget
Indrajeet last edited by
I have added a tab widget in my ui file.
In one of the tab of this tab widget I am dynamically creating the another tabwidget.
This creation of dynamic tabwidget I am doing on some button click SLOT.
So I want to remove or clear the tab each time the button is clicked and then create the tabwidget inside tab dynamically.
How to do this?
b1gsnak3 last edited by
Do you mean you have double tab widgets (tab widget inside a tab of a tabwidget)? Or do you mean you are removing one tab from your tabwidget and adding another one?
Jeroentjehome last edited by
Hmm, Maybe a strange way of doing things, but why a tab widget in a tab widget. Isn't it better to have a listwidget in the tab and add/remove items there, use the selected slots there to select the stackedwidget item to display next to it. That is probably much more common and user friendly. But to get to the question asked. the tabWidget is easily created with
@QTabWidget dynTab = new QTabWidget(ui->tabWidget);@
The dynamic tab needs to be hold by a layout or a frame to be added to the main tabwidget IYAM.
The insert new tabs to it and all done. Remember that remove tab doesn't really remove the widget it holds!! You have to remove the allocated memory yourself (or wait for the program to be closed, it will be done then) or keep it in memory and add it again to the tabwidget if needed.
(not tested this idea, but hopes this gives some help)