Hello
I'm working on a project that requires creation and management of rectangles, that can be change throughout the course of time, according to some data received by a web socket.
What matters here, is that I want the QMLObjects to be fully "mirrored" in C++ classes, so we only change one object and those changes reflect to the qml rectangles.

So, according to the official QML documentation(http://doc.qt.io/qt-5/qtqml-javascri...tcreation.html), to dynamically create a rectangle I'm using this code:
Qt Code:
  1. function buildZone() {
  2. var component;
  3. var zone;
  4. component = Qt.createComponent("Zone.qml");
  5. zone = component.createObject(layout, {
  6. "x": zoneMapper.x,
  7. "y": zoneMapper.getY()+30,
  8. "width": zoneMapper.getWidth(),
  9. "height": zoneMapper.getHeight(),
  10. "objectName": zoneMapper.getId(),
  11. "color":"red"});
  12. zoneMappers.push(zoneMapper);
  13. }
To copy to clipboard, switch view to plain text mode 

This "zoneMapper" is an object that it is instantiated in the main.cpp of a custom class, that has x with a property as follows:
Q_PROPERTY(int x READ getX WRITE setX NOTIFY xChanged)

So when you change "x", it calls a setter in the C++ class, and everything is in sync.
Problem is, when I use a button to change zonneMapper.x, like this:
Qt Code:
  1. Button{
  2. id:button1
  3. objectName:"Button1"
  4. text:"Button1Text"
  5. onClicked: {
  6. zoneMapper.x +=50;
  7. }
  8. }
To copy to clipboard, switch view to plain text mode 
The dynamically created rectangle doesn't move, although the "setter" and "getter" in the class are called (I can check this with breakpoints)

I noticed though, if I do this, with a static rectangle:
Qt Code:
  1. Rectangle{
  2. id: staticRect
  3. x:zoneMapper.x
  4. y:30
  5. width:50
  6. height:50
  7. color:"yellow"
  8. }
To copy to clipboard, switch view to plain text mode 

It moves!!!
I have another problem here, regarding the "mapping" of several rectangles, but's that's stuff for another episode
So, is there a way to bind an object in C++ to a dinamically created qml object?

Thank you