listmodel

QML ListModel append broken for object containing an array?

我是研究僧i 提交于 2019-12-12 04:12:15
问题 ListModel produces unexpected and pretty much broken results when trying to insert a JS object which contains an array: property ListModel model : ListModel {} Component.onCompleted: { var a = [1, 2, 3, 4, 5] console.log(a) model.append({"a" : a}) console.log(model.get(model.count - 1)) console.log(model.get(model.count - 1).a) Output is: qml: [1,2,3,4,5] qml: QObject(0x3cccd58) qml: QQmlListModel(0x3cd0978) However, if the array is joined into a string, it works as expected: console.log(a) a