开发者

Adding elements at runtime

How can I add an element to any view at runtime?

for example, when s开发者_JAVA技巧ome signal is fired, the application should add a rectangle to a specific row.

Thanks,


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜