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. Remove row while model (QSqlRelationalTableModel) is dirty
Forum Updated to NodeBB v4.3 + New Features

Remove row while model (QSqlRelationalTableModel) is dirty

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 1 Posters 477 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.
  • P Offline
    P Offline
    Panoss
    wrote on last edited by Panoss
    #1

    I add a new row in my model (QSqlRelationalTableModel).
    So, it's dirty (model ->dirty returns true) . (EditStrategy is OnManualSubmit)

    If I want to cancel the new record and delete it from the model while it is dirty, what should I do?

    I tried:

     model->removeRow(model->rowCount());
    

    but fails, the row is not removed from model.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Panoss
      wrote on last edited by
      #2

      I replaced:

      model->rowCount()
      

      with:

      mapper->currentIndex()
      

      and seems to work.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Panoss
        wrote on last edited by Panoss
        #3

        But the model>isDirty() remains true...
        How can I make it become false?
        I tried:

        mapper->submit();
        model->submitAll();
        model->submit(); 
        

        but they fail.

        EDIT: model->revertAll() seems to set isDirty to false.

        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