QTabBar has a signal for when tabs are moved so you should be able to keep the index of the "first tab" updated.

Or you just keep a pointer to that tab's widget and query its current index with QTabWidget::indexOf() before starting removing.

Cheers,
_