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. Correct Use of QAbstractTableModel::beginInsertRows() for non-consecutive rows
Forum Updated to NodeBB v4.3 + New Features

Correct Use of QAbstractTableModel::beginInsertRows() for non-consecutive rows

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 667 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.
  • F Offline
    F Offline
    frankiefrank
    wrote on 16 Jul 2014, 18:03 last edited by
    #1

    What should I do if I need to insert data rows into the model but the data goes into different, non-consecutive rows?

    In my case, the data has a QDateTime timestamp and the model might need to add data from previous or future timestamps.

    Docs say "Specify the first and last row numbers for the span of rows you want to insert into an item in a model.".

    So let's say I have 10 rows in my model. Now I got 4 new items that need to be inserted. But there's a chance that some would need to be prepended, some would go in the middle and some would be appended.

    Am I supposed to calculate the destinated ranges beforehand, and then call beginInsertRows() for each consecutive range?

    "Roads? Where we're going, we don't need roads."

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 16 Jul 2014, 20:44 last edited by
      #2

      Hi,

      That's what I would do, it will also allow views to react properly

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      1/2

      16 Jul 2014, 18:03

      • Login

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