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

Menu in a window with a custom title bar pops up incorrectly positioned

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.12.4, 5.12.9, 5.15.0
    • Quick: Controls 2
    • macOS 10.15.5 (19F101)
    • macOS

    Description

      I have a very simple menu in a window:

      import QtQuick 2.12
      import QtQuick.Controls 2.12
      import QtQuick.Window 2.12
      
      Window {
          id: root
          visible: true
          width: 640
          height: 480
          flags: Qt.CustomizeWindowHint | Qt.WindowMinMaxButtonsHint
      
          MouseArea {
              property point previousPosition
      
              anchors.left: parent.left
              anchors.right: parent.right
              anchors.top: parent.top
              height: 40
      
              onPressed: previousPosition = Qt.point(mouse.x, mouse.y)
              onPositionChanged: {
                  root.setX(root.x + mouse.x - previousPosition.x)
                  root.setY(root.y + mouse.y - previousPosition.y)
              }
          }
      
          Rectangle {
              anchors.centerIn: parent
              width: 200
              height: width
              color: 'red'
      
              MouseArea {
                  anchors.fill: parent
                  acceptedButtons: Qt.RightButton
                  onClicked: menu.popup()
              }
      
              Menu {
                  id: menu
      
                  MenuItem { text: 'Item 1' }
                  MenuItem { text: 'Item 2' }
                  MenuItem { text: 'Item 3' }
              }
          }
      }
      

      When the top of the window sticks to the top of the working space (i.e. to the bottom of the standard macOS menu), the menu pops up at the incorrect location. Otherwise it works normally. You can drag by the title bar in order to move the window to the top.

      I have also attached the code as a stand-alone project for your convenience.

      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
            ddobrev Dimitar Dobrev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes