diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index d8c37d6ca0..c9d6593662 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1888,6 +1888,31 @@ bool QApplication::event(QEvent *e) \obsolete */ +// ### FIXME: topLevelWindows does not contain QWidgets without a parent +// until create_sys is called. So we have to override the +// QGuiApplication::notifyLayoutDirectionChange +// to do the right thing. +void QApplicationPrivate::notifyLayoutDirectionChange() +{ + const QWidgetList list = QApplication::topLevelWidgets(); + QWindowList windowList = QGuiApplication::topLevelWindows(); + + // send to all top-level QWidgets + for (int i = 0; i < list.size(); ++i) { + QWidget *w = list.at(i); + windowList.removeAll(w->windowHandle()); + QEvent ev(QEvent::ApplicationLayoutDirectionChange); + QCoreApplication::sendEvent(w, &ev); + } + + // in case there are any plain QWindows in this QApplication-using + // application, also send the notification to them + for (int i = 0; i < windowList.size(); ++i) { + QEvent ev(QEvent::ApplicationLayoutDirectionChange); + QCoreApplication::sendEvent(windowList.at(i), &ev); + } +} + /*! \fn void QApplication::setActiveWindow(QWidget* active) diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 860e89bb4f..29c6902c78 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -116,6 +116,7 @@ public: QApplicationPrivate(int &argc, char **argv, int flags); ~QApplicationPrivate(); + virtual void notifyLayoutDirectionChange(); virtual void notifyActiveWindowChange(QWindow *); virtual bool shouldQuit();