QMenu: Adjust the position of the submenu

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 <tmartsum@gmail.com>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
bb10
Wang Fei 2022-06-07 13:40:02 +08:00 committed by Fei Wang
parent e35fc908fd
commit e57ab1b454
1 changed files with 1 additions and 1 deletions

View File

@ -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()) {