diff options
author | Gabriel de Dietrich <gabriel.dedietrich@digia.com> | 2013-06-13 16:23:50 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-06-14 17:10:59 +0200 |
commit | 87b603080a300f865643a7c6c2c62a5cc795343b (patch) | |
tree | 0ed2b624872736c9df0971ec4a1ead5ee39b75e2 /src/controls/qquickmenupopupwindow.cpp | |
parent | 614219ff50e67cd5141e936cf01e699778927322 (diff) | |
download | qtquickcontrols-87b603080a300f865643a7c6c2c62a5cc795343b.tar.gz |
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: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'src/controls/qquickmenupopupwindow.cpp')
-rw-r--r-- | src/controls/qquickmenupopupwindow.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/controls/qquickmenupopupwindow.cpp b/src/controls/qquickmenupopupwindow.cpp index a8f2a153..b44b082c 100644 --- a/src/controls/qquickmenupopupwindow.cpp +++ b/src/controls/qquickmenupopupwindow.cpp @@ -66,8 +66,16 @@ void QQuickMenuPopupWindow::show() posy = pos.y(); } - posx += parentWindow->geometry().left(); - posy += parentWindow->geometry().top(); + if (parentWindow->parent()) { + // 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) { |