Skip to content

Commit c60b323

Browse files
committed
SplitTabWidget: better handling of spliting out (#131)
Properly parent tabs when moving widgets between splits. Fixes a crash, and widgets being deleted on some scenarios. closes #131
1 parent ba20bea commit c60b323

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/widgets/SplitTabWidget.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,12 @@ void SplitTabWidget::moveTabToNewSplit(QWidget *widget) {
449449
auto oldTab = qobject_cast<QTabWidget *>(widget->parentWidget()->parentWidget());
450450
auto index = oldTab->indexOf(widget);
451451
auto text = oldTab->tabText(index);
452-
currentTabWidget->addTab(widget, text);
453-
oldTab->removeTab(index);
452+
auto tooltip = oldTab->tabToolTip(index);
453+
454+
// The widget is automatically removed from oldTab when reparented
455+
auto newIndex = currentTabWidget->addTab(widget, text);
456+
currentTabWidget->setTabToolTip(newIndex, tooltip);
457+
currentTabWidget->setCurrentIndex(newIndex);
454458
widget->setFocus();
455459
}
456460

0 commit comments

Comments
 (0)