Hi all!
I would like to create something similar to the corkboard qml example. On a screen I have some items, which I can move, resize, rotate, and I can store these properties.
I created a model inherited from QAbstractListModel on C++ side. It populates data well.
On the QML side I show it in a Repeater, like this:
Qt Code:
Repeater { id: myRepeater model: dayScreenModel DayScreenEntry { x: position.x y: position.y text: title }To copy to clipboard, switch view to plain text mode
position, title, size, rotation comes from the C++ model.
It works fine.
But how can I achieve modification of these data?
I found a way:
in the model, created a public slot:
void updateData(int index, QString role, QVariant value);
and, in the DayScreenEntry.qml I can call like this:
myRepeater.model.updateData(index, "title", "NewTitle")
I can refresh the data in code, and it populates also to the qml side, shows the changes.
But, I have some problems with it:
- it's not 'elegant' - Is it possible somehow to call the 'setData' function of the model?
- on QML side, i have to write the model name in the delegate - I can use it only for this model, have to know the model name.
Do You know any other way to get this stuff working?
Bookmarks