XMLWordPrintable

Details

    • Technical task
    • Resolution: Unresolved
    • P2: Important
    • 6.9
    • QML: Tooling

    Description

      qmllint (current dev) suggests to replace "var" property with function,
      for code bellow.

      Property "nextCheckState" is a variant property. It may or may not be a method. Use a regular function instead.
      

      But this suggestion have no sense for me.

      QML doesn't support function "override" in the same manner as C++, hence to allow user change part of logic of your component this logic should be inside property,
      and only "var" type is allowed if you want to save "function() {}" inside property.
      So how it possible to "use regular function instead" in such case ?

      Rectangle {
          id: control
      
          property var nextCheckState: function(prevState) {
              return !prevState;
          }
      
          BoolValue {
              id: flag
          }
         MouseArea {
              anchors.fill: parent
              onClicked: {
                  flag.setOn(control.nextCheckState(flag.isOn));
              }
          }
      }
      

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-104220
          # Subject Branch Project Status CR V

          Activity

            People

              qtqmlteam Qt Qml Team User
              evgeniy_dushistov evgeniy_dushistov
              Votes:
              6 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There is 1 open Gerrit change