From b21c219811f2363002e3cc96c8cfef849aaa95a4 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 6 Nov 2015 11:03:15 +0100 Subject: [PATCH] Call setFocus() if it is a QAxHostWidget which is in a new active window The change 8c0f47cfae17a39137dec47aa0b9f3f9bedad introduced a problem where if the widget was being reparented had a valid HWND then it would cause the focus to change inside the already active window. Therefore we need to limit the times it does this to the case where we know it needs to be done which is the ActiveQt case. Change-Id: Ia85f5136661142b25952e0ebf66f8a43d9500d58 Reviewed-by: Friedemann Kleint Reviewed-by: Andy Shaw --- src/widgets/kernel/qapplication.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 647484ece1..078feb4b03 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -2248,8 +2248,10 @@ void QApplicationPrivate::notifyActiveWindowChange(QWindow *previous) QApplication::setActiveWindow(tlw); // QTBUG-37126, Active X controls may set the focus on native child widgets. if (wnd && tlw && wnd != tlw->windowHandle()) { - if (QWidgetWindow *widgetWindow = qobject_cast(wnd)) - widgetWindow->widget()->setFocus(Qt::ActiveWindowFocusReason); + if (QWidgetWindow *widgetWindow = qobject_cast(wnd)) { + if (widgetWindow->widget()->inherits("QAxHostWidget")) + widgetWindow->widget()->setFocus(Qt::ActiveWindowFocusReason); + } } }