summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index 40b8af663c..e2a07c0043 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -1942,10 +1942,14 @@ void QWidgetTextControlPrivate::contextMenuEvent(const QPoint &screenPos, const
if (!menu)
return;
menu->setAttribute(Qt::WA_DeleteOnClose);
- if (auto *window = static_cast<QWidget *>(parent)->window()->windowHandle()) {
- QMenuPrivate::get(menu)->topData()->initialScreenIndex =
+
+ if (auto *widget = qobject_cast<QWidget *>(parent)) {
+ if (auto *window = widget->window()->windowHandle()) {
+ QMenuPrivate::get(menu)->topData()->initialScreenIndex =
QGuiApplication::screens().indexOf(window->screen());
+ }
}
+
menu->popup(screenPos);
#endif
}