How to access a specific component

  • Hi
    I wrote a litte qml application which will create an Object of a Component every time a button is clicked.

    import QtQuick 2.6
    import QtQuick.Window 2.2
    Window {
        id: mainWindow
        visible: true
        width: 1280
        height: 720
        property int idNumberCounter: 1
         id: testComponent
               id: rectangleMade
               property int idNumber: 0
                width: 100
                height: 100
                x: 100*idNumber
                 border.color: "blue"
    //The button for creating 
            id: buttonMakeRectangle
            color: "red"
            width: 50
            height: 50
                anchors.fill: parent

    What I would like to do now is to have a second button, which will e.g. change the x-Value of the rectangle with the idNumber=3 (if available).

    Is there a way to access a specific component?

    FYI: Adding a MouseArea to the "rectagleMade" and simply perfom the work there is not possible, because in the real application this rectangles are controlled via dBus from another application. (it will be a windowing manager with QtWayland)

    Thanks for help


  • Moderators

    @outdoor_guy Check if you can add these newly created objects in a property variant and then later access it.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.