QML ListView filled by Javascript

前端 未结 1 1957
时光取名叫无心
时光取名叫无心 2021-02-09 04:09

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:22

    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)
提交回复
热议问题