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

MenuItem's checked property set by triggered when controlled by value

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Incomplete
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.11.2
    • Quick: Controls 2
    • None
    • Windows 10 x64, Intel platform, in-built UHD graphics.
    • Windows

      If you control a MenuItem's checked state using the checked property it can be overridden by clicking on the menu item.

      The example below can be added to an empty QML project or just viewed using qmlscene.exe.

       

      The expected behaviour is that only one menu item is ticked at a time.

      If you click on the "Reset Mode" item whilst the "Mode 0" menu item is checked they will both end up being checked. This is the simplest example I could produce.

      import QtQuick 2.11
      import QtQuick.Window 2.11
      
      import QtQuick.Controls 2.4
      
      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          property int mode: 0
      
          MenuBar {
              Menu {
                  title: "Mode"
      
                  MenuItem {
                      text: "Mode 0"
                      checkable: true
                      checked: 0 == mode
                      onTriggered: {
                          mode = mode + 1;
                      }
                  }
                  MenuItem {
                      text: "Reset Mode"
                      checkable: true
                      checked: 0 != mode
                      onTriggered: {
                          mode = 0;
                      }
                  }
              }
          }
      }
      

       

        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
            petermj Peter Myerscough-Jackopson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes