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

Qml Menu, inherited property "opened" is not working

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P2: Important
    • None
    • 6.5.0 Beta3
    • Quick: Controls 2
    • None
    • 27adb3b91 (dev), 646063ed8 (6.5)

    Description

      The inherited property from PopUp : opened is not updated when Menu is open and close.

      So I can't use this property to toggle the visibility of a menu with a button

      import QtQuick
      import QtQuick.Controls
      import QtQuick.Window
      
      Window{
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          Button{
              id:button
              anchors.centerIn: parent
              text: "menu button"
              onClicked: {
                  print(menu.opened)
                  if(menu.opened){
                      menu.close()
                  }
                  else{
                      menu.open()
                  }
              }
          }
          Menu {
              id: menu
      
              x: 0
              y: parent.height/2 + button.height/2 + 10
      
              MenuItem {
                  text: "Choix 1"
              }
      
              MenuItem {
                  text: "Choix 2"
              }
          }
      }
      

      Attachments

        1. menu_opened.zip
          1 kB
          Léo Couturier

        Issue Links

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              leocouturier Léo Couturier
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: