diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index a6e6f1f..33aecbc 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -413,6 +413,7 @@ void CDockAreaWidget::insertDockWidget(int index, CDockWidget* DockWidget, bool Activate) { d->ContentsLayout->insertWidget(index, DockWidget); + DockWidget->setDockArea(this); DockWidget->tabWidget()->setDockAreaWidget(this); auto TabWidget = DockWidget->tabWidget(); // Inserting the tab will change the current index which in turn will @@ -428,7 +429,6 @@ void CDockAreaWidget::insertDockWidget(int index, CDockWidget* DockWidget, { setCurrentIndex(index); } - DockWidget->setDockArea(this); d->updateTitleBarButtonStates(); } diff --git a/src/DockWidgetTab.cpp b/src/DockWidgetTab.cpp index 167b2d7..c907ee0 100644 --- a/src/DockWidgetTab.cpp +++ b/src/DockWidgetTab.cpp @@ -463,15 +463,21 @@ void CDockWidgetTab::setActiveTab(bool active) bool AllTabsHaveCloseButton = d->testConfigFlag(CDockManager::AllTabsHaveCloseButton); bool TabHasCloseButton = (ActiveTabHasCloseButton && active) | AllTabsHaveCloseButton; d->CloseButton->setVisible(DockWidgetClosable && TabHasCloseButton); - if (d->IsActiveTab == active) - { - return; - } + bool UpdateFocusStyle = false; if (active && !hasFocus()) { - std::cout << "setFocus(Qt::OtherFocusReason);" << std::endl; setFocus(Qt::OtherFocusReason); + UpdateFocusStyle = true; + } + + if (d->IsActiveTab == active) + { + if (UpdateFocusStyle) + { + updateStyle(); + } + return; } d->IsActiveTab = active; updateStyle();