diff options
author | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-09-09 17:11:03 +0200 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@digia.com> | 2014-09-10 11:56:17 +0200 |
commit | d70e5ebe11a8eb22fe5e71945982d81991dc9f09 (patch) | |
tree | 81dde5c8b680fce109d35904e40dfb7206dc4619 /src/controls/qquickpopupwindow.cpp | |
parent | bc91574cca8b6f24968ab4e1cc11fe1fd10f3061 (diff) |
Fix menu popups positioning with window containersv5.3.2
Task-number: QTBUG-40883
Change-Id: I5c46c049b5890259d65f325adb59e15ebf29f84a
Reviewed-by: Robert Loehning <robert.loehning@digia.com>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src/controls/qquickpopupwindow.cpp')
-rw-r--r-- | src/controls/qquickpopupwindow.cpp | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/src/controls/qquickpopupwindow.cpp b/src/controls/qquickpopupwindow.cpp index eefeadb77..fe697d311 100644 --- a/src/controls/qquickpopupwindow.cpp +++ b/src/controls/qquickpopupwindow.cpp @@ -68,23 +68,16 @@ void QQuickPopupWindow::show() { qreal posx = x(); qreal posy = y(); - if (QQuickWindow *parentWindow = qobject_cast<QQuickWindow *>(transientParent())) { + // transientParent may not be a QQuickWindow when embedding into widgets + if (QWindow *tp = transientParent()) { if (m_parentItem) { - QPointF pos = m_parentItem->mapToItem(parentWindow->contentItem(), QPointF(posx, posy)); + QPointF pos = m_parentItem->mapToItem(m_parentItem->window()->contentItem(), QPointF(posx, posy)); posx = pos.x(); posy = pos.y(); } - - 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(); - } + QPoint tlwOffset = tp->mapToGlobal(QPoint()); + posx += tlwOffset.x(); + posy += tlwOffset.y(); } else if (m_parentItem && m_parentItem->window()) { QPoint offset; QQuickWindow *quickWindow = m_parentItem->window(); |