diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-06-14 15:38:47 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-06-14 16:37:37 +0200 |
commit | 428f20048a8b2648626a510c5f2c1d27ac8b273b (patch) | |
tree | 020e9d3e75d4fd0bf6547fb7d50478298198c136 /src | |
parent | 2e7234cc40b853c3e796556617b6bd05049fa192 (diff) |
Fix QStatusBar with widgets disappearing from QMainWindow
There is code that redirects QStatusBar messages to IOleInPlaceFrame.
It should not trigger when the statusbar has widgets. Add a helper function
to check this.
Fixes: QTBUG-99294
Pick-to: 6.4 6.3
Change-Id: I6854f3774bc6c31e6f184cc5b677419867011326
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/activeqt/control/qaxserverbase.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/activeqt/control/qaxserverbase.cpp b/src/activeqt/control/qaxserverbase.cpp index 46edbd0..88c3fd7 100644 --- a/src/activeqt/control/qaxserverbase.cpp +++ b/src/activeqt/control/qaxserverbase.cpp @@ -21,6 +21,7 @@ #include <qmetaobject.h> #include <qpixmap.h> #include <qregularexpression.h> +#include <qsizegrip.h> #include <qstatusbar.h> #include <qwhatsthis.h> #include <ocidl.h> @@ -3736,6 +3737,25 @@ HRESULT WINAPI QAxServerBase::Close(DWORD dwSaveOption) bool qax_disable_inplaceframe = true; +// Find a status bar to hook into, hide and redirect its messages to +// IOleInPlaceFrame if and only if the user did not explicitly show it or +// added some widgets (QTBUG-99294). +static QStatusBar *findStatusBar(QWidget *w) +{ + if (w == nullptr) + return nullptr; + QStatusBar *result = w->findChild<QStatusBar*>(); + if (result == nullptr) + return nullptr; + if (result->isVisible() && result->testAttribute(Qt::WA_WState_ExplicitShowHide)) + return nullptr; + for (auto child : result->children()) { + if (child->isWidgetType() && qobject_cast<QSizeGrip *>(child) == nullptr) + return nullptr; + } + return result; +} + /* Executes the steps to activate the control. */ @@ -3818,8 +3838,7 @@ HRESULT QAxServerBase::internalActivate() menuBar->hide(); menuBar->installEventFilter(this); } - statusBar = qt.widget ? qt.widget->findChild<QStatusBar*>() : nullptr; - if (statusBar && !statusBar->isVisible()) { + if (auto *statusBar = findStatusBar(qt.widget)) { const int index = statusBar->metaObject()->indexOfSignal("messageChanged(QString)"); QMetaObject::connect(statusBar, index, this, STATUSBAR_MESSAGE_CHANGED_SLOT_INDEX); statusBar->hide(); |