QML ListView filled by Javascript

前端 未结 1 1807
礼貌的吻别
礼貌的吻别 2021-02-09 03:39

I just realized that (according to some QML Bugreport) there is JSON Delegate for ListView missing. So I have two choices, fill it up by model created in Javascript or C++

1条回答
  •  忘了有多久
    2021-02-09 04:41

    Due to advice from mouli@irc.freenode.net#qt do this:

    file: gui.qml

    import "script.js" as Script
    
    model: ListModel { id: list_model_id }
    

    file: script.js

    function makeList(id){
        id.append({"name":"value1"});
        id.append({"name":"value2"});
    }
    

    call:

    Script.makeList(list_model_id)
    

    0 讨论(0)
提交回复
热议问题