Ah, hmm.
Without the need to add elements in QML code that would be easy: a custom model type would allow instantiation from QML and also provide complete control over its C++ API.
Ok, so you'll need a ListModel subtype that has additional functions.
Something like
// MyListModel
import QtQuick 2.0
ListModel {
function appendFromJSON(string jsonString) {
// get data from jsonString, call append()
}
}
// MyListModel
import QtQuick 2.0
ListModel {
function appendFromJSON(string jsonString) {
// get data from jsonString, call append()
}
}
To copy to clipboard, switch view to plain text mode
Then use MyListModel instead of ListModel.
Cheers,
_
P.S.: be sure you and the users understand the inherent limitations of ListModel/ListElement, e.g. can't deal with translatable strings.
This is usually only used for prototyping while real model data is not available or for very rare cases when data is fixed and does not contain user visible text.
Bookmarks