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. [SOLVED] Insert rows
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Insert rows

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 1.4k 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.
  • G Offline
    G Offline
    godbod
    wrote on last edited by
    #1

    Hello everyone,

    Would you please help me? I have a QML list of items. And I am using C++ bindings to manipulate a list showed in QML.
    I did implement this function :

    @void PatientModelpps::addPatient(const Patient &patient)
    {
    beginInsertRows(QModelIndex(), 0, 1);
    m_Patients << patient;
    endInsertRows();
    }@

    to add an Item, but it adds an item at the end on the list whereas I want it at the top of the list.
    What can I do ?

    Thanks.

    L'imagination est tout, c'est l’aperçu des futures attractions de la vie.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      There is not enough info, but in general you could try this:
      @
      // If m_Patients is a QList or QVector
      m_Patients.prepend(patient);
      @

      Hard to say anything more without more details.

      (Z(:^

      1 Reply Last reply
      0
      • G Offline
        G Offline
        godbod
        wrote on last edited by
        #3

        Okay. Thank you. I will try it soon...

        L'imagination est tout, c'est l’aperçu des futures attractions de la vie.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          godbod
          wrote on last edited by
          #4

          It does work ! Thanks you very much indeed.

          L'imagination est tout, c'est l’aperçu des futures attractions de la vie.

          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