Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QList<int> from qml

QList<int> from qml

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 356 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.
  • M Offline
    M Offline
    Marek
    wrote on last edited by
    #1

    Hi
    I have simple QList<int> which I'm passing to QML with this property:

    Q_PROPERTY(QList<int> days MEMBER m_days NOTIFY daysChanged)
    

    Now I have some function on C++ side to retrieve what has changed on QML side

    Q_INVOKABLE void setSchedData(QString role,QVariant value);
    

    I thought it should work stright away, because Qlist<int> is changed to Array when passing to QML and array is changed to QVariantList when going back to C++
    But this piece of QML code made me some headache:

     var tmp_days=Array.from(WateringSchedModel.days)
    //for(var i=0;i<WateringSchedModel.days.length;i++) {
    //    tmp_days.push(WateringSchedModel.days[i])
    //}
    tmp_days.push(index_role)
    WateringSchedModel.setSchedData("days_role",tmp_days)
    

    it works only with Array.from(exposed_from_cpp) or when I copy elements of days property to tmp_days (commented out), when I use Array.isArray(WateringSchedModel.days) it says false, typeof says object, simply writing:

    var tmp_days=[];
    tmp_days=WateringSchedModel.days
    

    does not work, however I can iterate through tmp_days as if it has been an array, what Am I missing here ?
    Best,
    Marek

    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