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

Qml Menu, inherited property "opened" is not working

XMLWordPrintable

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

      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"
              }
          }
      }
      

        1. menu_opened.zip
          1 kB
          Léo Couturier
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes