summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@nokia.com>2012-06-20 19:12:01 +0200
committerJens Bache-Wiig <jens.bache-wiig@nokia.com>2012-06-21 11:58:46 +0200
commitfcc66acff4226881ac90e65b96f3efc4429d7eaa (patch)
tree775709898ed992273ff40e454cc75b0ee0c04c47
parente5281b3dbd9ef2e14621e3eeacd1630c69b73b8e (diff)
downloadqtquickcontrols-fcc66acff4226881ac90e65b96f3efc4429d7eaa.tar.gz
Position popup menu correctly.
Change-Id: I6785f1caa55c60a5d9aa1567b1d5831ec7bbc896 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@nokia.com>
-rw-r--r--src/qtmenu.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/qtmenu.cpp b/src/qtmenu.cpp
index de41dbe5..39cdc054 100644
--- a/src/qtmenu.cpp
+++ b/src/qtmenu.cpp
@@ -116,14 +116,15 @@ void QtMenu::showPopup(qreal x, qreal y, int atActionIndex)
// x,y are in view coordinates, QMenu expects screen coordinates
// ### activeWindow hack
int menuBarHeight = 0;
- QWidget *window = QApplication::activeWindow();
+ QWindow *window = QGuiApplication::focusWindow();
QTopLevelWindow *tw = qobject_cast<QTopLevelWindow*>(window);
if (tw) {
QMenuBar *menuBar = tw->menuBar();
menuBarHeight = menuBar->height();
}
- QPoint screenPosition = window->mapToGlobal(QPoint(x, y+menuBarHeight));
+ int windowFrameHeight = window->frameMargins().top();
+ QPoint screenPosition = window->mapToGlobal(QPoint(x, y+menuBarHeight-windowFrameHeight));
setHoveredIndex(m_selectedIndex);
m_qmenu->popup(screenPosition, atAction);