Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to change the data in QAbstractlistModel?

How to change the data in QAbstractlistModel?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 338 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    QTLeearn
    wrote on last edited by QTLeearn
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved