Commit 87b60308 authored by Gabriel de Dietrich's avatar Gabriel de Dietrich Committed by The Qt Project
Browse files

Menu: Support QQuickWindows embedded in QWidgets


We translate the menu popup window by its transient parent origin
coordinates, but if it's embedded in a QWidget, we would only translate
by the transient parent's origin inside that QWidget. So, in this case.
we translate by the transient parent's origin in the global coordinate
reference system.

Task-number: QTBUG-31659
Change-Id: I09aa64f2d61d227d4fcd6d6e22a25453e1f2dc76
Reviewed-by: default avatarJ-P Nurmi <jpnurmi@digia.com>
No related merge requests found
Showing with 10 additions and 2 deletions
...@@ -66,8 +66,16 @@ void QQuickMenuPopupWindow::show() ...@@ -66,8 +66,16 @@ void QQuickMenuPopupWindow::show()
posy = pos.y(); posy = pos.y();
} }
posx += parentWindow->geometry().left(); if (parentWindow->parent()) {
posy += parentWindow->geometry().top(); // If the parent window is embedded in another window, the offset needs to be relative to
// its top-level window container, or to global coordinates, which is the same in the end.
QPoint parentWindowOffset = parentWindow->mapToGlobal(QPoint());
posx += parentWindowOffset.x();
posy += parentWindowOffset.y();
} else {
posx += parentWindow->geometry().left();
posy += parentWindow->geometry().top();
}
} }
if (m_itemAt) { if (m_itemAt) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment