diff --git a/5.15.2/qtbase/src/widgets/widgets/qwidgettextcontrol.cpp b/5.15.2/qtbase/src/widgets/widgets/qwidgettextcontrol.cpp index 40b8af6..e2a07c0 100644 --- a/5.15.2/qtbase/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/5.15.2/qtbase/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(parent)->window()->windowHandle()) { - QMenuPrivate::get(menu)->topData()->initialScreenIndex = + + if (auto *widget = qobject_cast(parent)) { + if (auto *window = widget->window()->windowHandle()) { + QMenuPrivate::get(menu)->topData()->initialScreenIndex = QGuiApplication::screens().indexOf(window->screen()); + } } + menu->popup(screenPos); #endif }