diff --git a/widgets/tabbar.cpp b/widgets/tabbar.cpp index 478d59a49..d655e7d9e 100644 --- a/widgets/tabbar.cpp +++ b/widgets/tabbar.cpp @@ -360,18 +360,23 @@ void TabBar::removeTab(int index) return; } - int currentIndex = d->tabProxy->native->currentIndex(); - + int oldCurrentIndex = d->tabProxy->native->currentIndex(); d->tabProxy->native->removeTab(index); QGraphicsWidget *page = d->pages.takeAt(index); - if (index == currentIndex) { - setCurrentIndex(currentIndex); + int currentIndex = d->tabProxy->native->currentIndex(); + + if (oldCurrentIndex == index) { + d->tabWidgetLayout->removeAt(1); } scene()->removeItem(page); page->deleteLater(); + if (oldCurrentIndex != currentIndex) { + setCurrentIndex(currentIndex); + } + d->updateTabWidgetMode(); d->tabProxy->setPreferredSize(d->tabProxy->native->sizeHint()); }