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. Update the table's ID column when you remove a row from a model.

Update the table's ID column when you remove a row from a model.

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.4k Views
  • 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.
  • E Offline
    E Offline
    Edico
    wrote on last edited by
    #1

    When I remove a row from a table I want the ID column to be updated, that is the rows after the one deleted to have minus 1 (if can be updated when I remove multiple rows at once is even better). Does QSqlRelationalTableModel has something for updating the table's ID column or I must do that manualy?

    (I also use a proxy model with QSqlRelationalProxyModel. I don't know if that is relevant).

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Database id fields do not work that way. The whole point of that field is that it does not change.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lgeyer
        wrote on last edited by
        #3

        I'm not quite sure about the ID you are referring to but if you are talking about the ID as a primary key (as in the relational table model) then no, there is no such functionality.

        Besides that (and yes, I know this is philosopihcal question) you should never alter or reuse a primary key in a database, especially if it is auto-generated (sequenced). If you want a continous numbering of your items either use an additional column or a 'virtual' column which is created no the fly. But do not abuse your primary key for this.

        1 Reply Last reply
        0
        • E Offline
          E Offline
          Edico
          wrote on last edited by
          #4

          Ok, I wont modify it. I'm sorry I didn't knew that.

          Thanks!

          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