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 keep a pointer to a QAbstractItemModel cell which its index changes?
Qt 6.11 is out! See what's new in the release blog

How to keep a pointer to a QAbstractItemModel cell which its index changes?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.1k 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.
  • A Offline
    A Offline
    alizadeh91
    wrote on last edited by
    #1

    We have a QAbstractItemModel which we dynamically insert rows in it. We want to keep a pointer to every newly added rows in order to be able to change its color later. QModelIndex cannot be used, because it just points at the location specified by rows and columns, and since the model is dynamically updated, it's not the same cell the next time. How can we save a pionter to a specific cell (regardless of its row and column)?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Saugglocke
      wrote on last edited by
      #2

      Hm, maybe a QPersistentModelIndex would do the trick?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alizadeh91
        wrote on last edited by
        #3

        Thank you. it did the trick.

        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