From f54869fbf7810092dd79f5fee8bd7573badaac91 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Mon, 11 May 2020 16:29:58 +0200 Subject: [PATCH] Improved setting of CDockWidgetTab focus --- src/DockManager.cpp | 19 +++++++++++++++++-- src/DockWidgetTab.cpp | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/DockManager.cpp b/src/DockManager.cpp index 2394d85..37a2cdc 100644 --- a/src/DockManager.cpp +++ b/src/DockManager.cpp @@ -879,14 +879,29 @@ CIconProvider& CDockManager::iconProvider() //=========================================================================== -void CDockManager::onFocusObjectChanged(QObject *focusObject) +void CDockManager::onFocusObjectChanged(QObject *focusObject) { auto FocusWidget = qobject_cast(focusObject); if (!FocusWidget) { return; } - auto DockWidget = internal::findParent(FocusWidget); + + CDockWidget* DockWidget = nullptr; + + std::cout << "CDockManager::onFocusObjectChanged " << focusObject->objectName().toStdString() + << " meta: " << focusObject->metaObject()->className() << std::endl; + + auto DockWidgetTab = qobject_cast(focusObject); + if (DockWidgetTab) + { + DockWidget = DockWidgetTab->dockWidget(); + } + else + { + DockWidget = internal::findParent(FocusWidget); + } + if (!DockWidget) { return; diff --git a/src/DockWidgetTab.cpp b/src/DockWidgetTab.cpp index d290104..7597d05 100644 --- a/src/DockWidgetTab.cpp +++ b/src/DockWidgetTab.cpp @@ -285,6 +285,7 @@ CDockWidgetTab::CDockWidgetTab(CDockWidget* DockWidget, QWidget *parent) : setAttribute(Qt::WA_NoMousePropagation, true); d->DockWidget = DockWidget; d->createLayout(); + setFocusPolicy(Qt::ClickFocus); } //============================================================================