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

QML var property emits change notification when unchanged

    XMLWordPrintable

Details

    Description

      import QtQuick 2.4
      
      Item {
          id: root
      
          property int theNum
      
          onTheNumChanged: {
              console.log("theNum", theNum)
          }
      
          property var theOtherNum : 10
      
          onTheOtherNumChanged: {
              console.log("theOtherNum", theOtherNum)
          }
      
          Timer {
              running: true
              repeat: true
              property bool invert
              onTriggered: {
                  theNum = JSON.parse(JSON.stringify(theNum))
                  theOtherNum = JSON.parse(JSON.stringify(theOtherNum))
              }
          }
      }
      

      This results in

      qml: theOtherNum 10
      qml: theOtherNum 10
      qml: theOtherNum 10
      qml: theOtherNum 10
      

      repeated. If this is intentional (because we are actually setting a different javascript object even if it's the same value, for example), it should perhaps be documented here: http://doc.qt.io/qt-5/qml-var.html#change-notification-semantics

      Attachments

        Issue Links

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

          Activity

            People

              Unassigned Unassigned
              ske Steve
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes