Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在运行时将元素添加到任何视图? 例如,当某个信号被触发时,应用程序应该向特定行添加一个矩形。 谢谢,
使用组件应该可以解决问题。
MySignalSource { Row { id: myRow anchors.fill: parent } Component { id: myRectComp Rectangle { width: 50 height: 50 } } onSignalFired: { var rect = myRectComp.createObject(myRow) rect.color = "black" } }
未经测试,但它应该像那样工作。