How to close all tabs but active in QTabWidget
, when i know a active tab index, and counts of tabs?
The function of closing all tabs is tabwidget->clear();
Have you tried this?
// remove all tabs after current
for (int i = tabWidget.count() - 1; i > tabWidget.currentIndex(); --i) {
tabWidget.removeTab(i);
}
// current tab is now the last, therefore remove all but the last
for (int i = tabWidget.count(); i > 1; --i) {
tabWidget.removeTab(0);
}