I'm having some problems with removing tabs from QTabWidget. I have this QTabWidget with a main tab, named (surprise!) mainTab. At runtime the user can open several new tabs to view text documents. In order to close these tabs again I have provided a push button, cmdClear. The code for the button is:
void QtTextSearcher::on_cmdClear_clicked()
{
int count = ui.mainTab->count();
int i = 1;
for (i=1; i<count; ++i)
{
ui.mainTab->widget(i)->deleteLater();
ui.mainTab->removeTab(i);
}
ui.txtOutput->clear();
ui.txtLog->append("Cleared");
}
void QtTextSearcher::on_cmdClear_clicked()
{
int count = ui.mainTab->count();
int i = 1;
for (i=1; i<count; ++i)
{
ui.mainTab->widget(i)->deleteLater();
ui.mainTab->removeTab(i);
}
ui.txtOutput->clear();
ui.txtLog->append("Cleared");
}
To copy to clipboard, switch view to plain text mode
When I press the buttton it doesn't delete all the document tabs however, it seems to always forget some. How come? I want it to delete all the tabs save the first mainTab.
Also: How can I position my QTabWidget like in the Assistant? In the Assistant the Tabwidgets are touching the toolbar, in designer I can't seem to get my Tabwidget anywhere near the edges of the mainwindow.
Bookmarks