XMLWordPrintable

Details

    • Technical task
    • Resolution: Unresolved
    • P2: Important
    • 6.8
    • 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

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

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

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes