How to change the data in QAbstractlistModel?
Unsolved
General and Desktop
-
hi, I am new to Qt/QML, this is maybe a basic function. I want to use QAbstractlistModel to provide 2 roles of data to QML's listview model.
QHash<int, QByteArray> myModel::roleNames() const { QHash<int, QByteArray> roles; roles[TimerRole] = "time"; roles[TitleRole] = "title"; return roles; }
and in QML I have the following:
model: myModel delegate: //sth time: model.time // editable
I also have a Q_PROPERTY in another class:
Q_PROPERTY(QDateTime currentTime READ currentTime WRITE setCurrentTime NOTIFY currentTimeChanged)
All I want to do is to change the model.time in qml with QDateTime currentTime, should I use QAbstractlistModel::setData( )? If yes, when to call setData and which aeguments should be passed into it?
Thank you in advance