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

Qt Quick Controls Menu can appear at the wrong position when DPI Awareness is enabled

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.2.10, 6.5.3, 6.6.1
    • Quick: Controls 2
    • Windows 10 22H2, MSVC 2019 x64
    • Windows

    Description

      Code
      Adapted from https://doc.qt.io/qt-6/qml-qtquick-controls-menu.html#details

      import QtQuick
      import QtQuick.Controls.Basic
      
      Window {
          width: 1600
          height: 480
          visible: true
      
          MouseArea {
              anchors.fill: parent
              acceptedButtons: Qt.RightButton
              onClicked: contextMenu.popup()
      
              Menu {
                  id: contextMenu
                  MenuItem { text: "Cut" }
                  MenuItem { text: "Copy" }
                  MenuItem { text: "Paste" }
              }
          }
      }
      
      

       

      Steps to reproduce

      1. Set up 2 screens with different DPIs (e.g. 100% on Screen 1, 200% on Screen 2)
      2. Run the code above with -platform windows:dpiawareness=1 or -platform windows:dpiawareness=2
      3. While the window is contained within one screen only, right-click inside various parts of the window
      4. Move the window so that it spans both screens
      5. Right-click inside the window within the first screen
      6. Right-click inside the window within the second screen

       

      Outcomes

      • Step #3: The context menu always pops up at the mouse cursor (expected)
      • Steps #5 and #6: The context menu pops up at the mouse cursor on one screen (expected), but pops up far away from the mouse cursor on the other screen (NOT expected)

       

      Notes

      • Which screen gets the wrong position depends on which screen the window is "adapted" to. The window changes size as you move it between screens and it "adapts" to the new DPI.
      • If you repeat this test on Qt Creator or Microsoft Notepad or Mozilla Firefox, the context menu always pops up at the expected position.

       

      Workaround
      Run the code with dpiawareness=0. (This seems to be the opposite problem as QTBUG-102982 )

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            skoh-qt Sze Howe Koh
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes