Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-31659

Menu::popup() misinterprets mouse position when QQuickView is embedded in a QWidget

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.1.1
    • 5.1.0 Beta 1
    • None
    • Windows 7 x86, qt-windows-opensource-5.1.0-beta1-msvc2010-x86-offline.exe
    • 87b603080a300f865643a7c6c2c62a5cc795343b

    Description

      // MenuScene.qml
      import QtQuick 2.1
      import QtQuick.Controls 1.0
      
      Rectangle {
      	id: root
      	width: 800
      	height: 600
      
      	Menu {
      		id: rootMenu
      		MenuItem {text: "Item 1"}
      		MenuItem {text: "Item 2"}
      	}
      
      	MouseArea {
      		anchors.fill: parent
      		onClicked: rootMenu.popup()
      	}
      }
      
      // widget.cpp
      Widget::Widget(QWidget *parent): QWidget(parent)
      {
      	QQuickView* view = new QQuickView(QUrl("MenuScene.qml"));
      	view->setResizeMode(QQuickView::SizeRootObjectToView);
      
      	QVBoxLayout *layout = new QVBoxLayout();
      	layout->addWidget(QWidget::createWindowContainer(view));
      	this->setLayout(layout);
      }
      

      When clicking inside the window, the menu pops up in the wrong area – It doesn't seem to take into account the widget's position on the screen (e.g. When clicking on the top-left corner of the QQuickView, the menu will pop up in the top-left corner of the screen)

      Also, when I move the widget to a secondary screen and click there, the menu still pops up on the primary screen.

      Attachments

        For Gerrit Dashboard: QTBUG-31659
        # Subject Branch Project Status CR V

        Activity

          People

            dedietri Gabriel de Dietrich (drgvond)
            jksh Sze Howe Koh
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes