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

Qt.rect objects from C++ properties are readonly

    XMLWordPrintable

Details

    • 76da60b5ad388b6873f496b07b2c3ccabe9c9490

    Description

      If I make a rectangle with var foo = Qt.rect() 

      I can do foo.x = 100;

      If I make the rectangle with var foo = someCppObject.rectProperty

       foo.x = 100 silently has no effect.

       

      Given it should be a copy of the data (like int or strings) I should be able to modify it.

       

      Simple code example explains the problem:

      import QtQuick 2.7
      import QtQuick.Window 2.0
      
      Window {
          visible: true
          width: 640
          height: 680
          title: qsTr("qtbug64115")
      
          Item {
              id: root
              Component.onCompleted: {
                  console.log("=====PART 1=====")
                  var rect = Qt.rect(50, 50, 100, 100)
                  console.log(rect.x) //outputs 50
                  rect.x += 500
                  console.log(rect.x) //outputs 550
      
                  console.log("=====PART 2=====")
      
                  var rect2 = root.childrenRect
                  console.log(rect2.x) //outputs 50
                  rect2.x += 500
                  console.log(rect2.x) //BUG!!! Should be 550, output is still 50
              }
              Item {
                  x: 50
                  width: 100
                  y: 50
                  height: 100
              }
          }
      }
      

      Attachments

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

        Activity

          People

            shausman Simon Hausmann
            davidedmundson David Edmundson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes