From e57ab1b454255b5d64b8463cc3ccdb96e7de836e Mon Sep 17 00:00:00 2001 From: Wang Fei Date: Tue, 7 Jun 2022 13:40:02 +0800 Subject: [PATCH] QMenu: Adjust the position of the submenu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the submenu is about to exceed the screen, set the position of the submenu to the left border of the main menu Fixes: QTBUG-104050 Change-Id: I8935f1bfceb93cfa1097391689f4233991394978 Reviewed-by: Thorbjørn Lund Martsum Reviewed-by: Richard Moe Gustavsen --- src/widgets/widgets/qmenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index adf538b37a..3c49ba5af4 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -3579,7 +3579,7 @@ void QMenu::internalDelayedPopup() const QRect actionRect(d->actionRect(d->currentAction)); QPoint subMenuPos(mapToGlobal(QPoint(actionRect.right() + subMenuOffset + 1, actionRect.top()))); if (subMenuPos.x() > screen.right()) - subMenuPos.setX(QCursor::pos().x()); + subMenuPos.setX(geometry().left()); const auto &subMenuActions = d->activeMenu->actions(); if (!subMenuActions.isEmpty()) {