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

[Qt6] Allow properties to be made readonly at runtime.

    XMLWordPrintable

Details

    Description

      A readonly binding cannot be broken. The value of the property will be exclusively modified by the binding evaluation engine. It will act as an guard against broken bindings.

      Possible Syntax => Qt.readonlyBinding(..)
      	
      property int a: 12
      property int b: a
      
      Component.onCompleted: {
       console.log("Value of b: ",b); // Value of b: 12
       b = Qt.readonlyBinding( () => a+20 );
       b = 50;  // TypeError: Cannot assign to readonly property "b"
       console.log("Value of b: ",b); // Value of b: 32
       
       myComponent.createObject(root,{ "height": Qt.readonlyBinding( () => root.height/10 ), "width": Qt.readonlyBinding( () => root.width/10 ) });
      }
      

      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
            adrian.gabureanu Adrian Gabureanu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes