Question


How can I add an element to any view at runtime?
for example, when some signal is fired, the application should add a rectangle to a specific row.
Thanks,

Was it helpful?

Solution

Using Component should do the trick.

MySignalSource {
    Row {
        id: myRow
        anchors.fill: parent
    }

    Component {
        id: myRectComp
        Rectangle {
            width: 50
            height: 50
        }
    }

    onSignalFired: {
        var rect = myRectComp.createObject(myRow)
        rect.color = "black"
    }
}

Not tested, but it should work like that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top