Results 1 to 3 of 3

Thread: QSqlTableModel Dirty Flag?

  1. #1
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default QSqlTableModel Dirty Flag?

    Hi Guys and Gals

    Other than iterating over every index in the model with QSqlTableModel::isDirty(), is there a good way to tell if a QSqlTableModel is in need of a call to submitAll() or revertAll()?

    I track my own row insertions and deletions. For edits I have been catching the model's dataChanged() signal but it gets sent when a cell is edited (and not cancelled) even if the value does not change, i.e. press F2 to edit the cell them move off it without changing the value. The isDirty() method similarly returns true for this cell.

    There does not seem to be a good flag that could be used to enable/disable a Commit/Revert button pair.

    Cheers
    Chris W

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSqlTableModel Dirty Flag?

    You can reimplement QAbstractItemModel::setData to ignore such edits and at the same place you can mark the model as dirty.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    ChrisW67 (4th September 2009)

  4. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSqlTableModel Dirty Flag?

    I did more-or-less what you describe.

Similar Threads

  1. Replies: 4
    Last Post: 9th May 2008, 17:02
  2. Replies: 2
    Last Post: 23rd February 2008, 01:58

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.