Dynamically create ListModel in QML

前端 未结 3 1219
花落未央
花落未央 2021-02-05 22:37

When I need to create any QML component in runtime, I can use that guide: http://qt-project.org/doc/qt-5/qtqml-javascript-dynamicobjectcreation.html

i.e. just call Qt.cr

3条回答
  •  -上瘾入骨i
    2021-02-05 22:51

    Try this:

    Component {
        id: someComponent
        ListModel {
        }
    }
    
    function createModel(parent) {
        var newModel = someComponent.createObject(parent);
        return newModel;
    }
    

提交回复
热议问题