I dont think the connect part is right..
On on_tabWidget_tabCloseRequested(int index)
you should call ui->tabWidget->removeTab(index)
not connect a signal ..
I think that you create extra signals and thats why you remove all tabs after the tab you tried to close.
EDIT:
To expand a bit:
I think, on first click no tabs get deleted, but you create a connection to delete a tab with the on_tabWidget_tabCloseRequested(int index)
. On your second try you again, create a connection with on_tabWidget_tabCloseRequested(int index)
and call closeTab
. On your third try you create another connection and call closeTab
twice with the same index, so the tab you clicked is deleted and the next one ...