diff options
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r-- | src/widgets/widgets/qwidgettextcontrol.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 024713fad3..9fe6e3e1e3 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1943,8 +1943,12 @@ 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()->initialScreen = window->screen(); + + if (auto *widget = qobject_cast<QWidget *>(parent)) { + if (auto *window = widget->window()->windowHandle()) + QMenuPrivate::get(menu)->topData()->initialScreen = window->screen(); + } + menu->popup(screenPos); #endif } |