Results 1 to 6 of 6

Thread: QSqlTableModel and QTableView critics.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  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 Re: QSqlTableModel and QTableView critics.

    Quote Originally Posted by Avrohom View Post
    I came across several issues using them both, which I think causes one to conclude that those components are not really suitable for real-world database applications. I hope that someone can prove me wrong.
    As a blanket statement, I don't think this is warranted. There are quite a few idiosyncrasies that make using them a bit more awkward than they could have been.

    For example, if you share a QSqlTableModel on manual submit between two views and edit through one of them you get the situation where edits to existing rows, and new rows, are seen in the other view immediately (no commitAll() required) , but deleted rows remain visible until all changes are committed to the database. In the edited view the deleted row is marked "!" in the vertical header view (if visible). In the other view this is not the case and I've not found another way to determine if a row is scheduled for deletion. Signals can do some of this if he second view is open when the delete is made, but are not useful if you open the second view later.

  2. #2
    Join Date
    Jan 2009
    Posts
    14
    Thanks
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: QSqlTableModel and QTableView critics.

    Quote Originally Posted by ChrisW67 View Post
    For example, if you share a QSqlTableModel on manual submit between two views and edit through one of them you get the situation where edits to existing rows, and new rows, are seen in the other view immediately (no commitAll() required) , but deleted rows remain visible until all changes are committed to the database. In the edited view the deleted row is marked "!" in the vertical header view (if visible). In the other view this is not the case and I've not found another way to determine if a row is scheduled for deletion. Signals can do some of this if he second view is open when the delete is made, but are not useful if you open the second view later.
    How do you delete those rows? Have you tried view->removeRow?

  3. #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 and QTableView critics.

    Removing the row is a function of the model, not the view: QSqlTableModel::removeRow().
    With OnManualSubmit the removed row remains visible in the view with a marker, so usually I use a QTableView::hideRow() to actually hide the row from view.

    In the secondary view the removed row remains visible until QSqlTableModel::commitAll() while other modifications are reflected in real time (i.e. not waiting until they are written to the database). It's this inconsistency that causes me angst.

Similar Threads

  1. QSqlTableModel, QTableView and complex queries
    By Walter in forum Qt Programming
    Replies: 8
    Last Post: 15th November 2009, 01:20
  2. Replies: 2
    Last Post: 6th January 2009, 20:55
  3. QSqlTableModel and QTableView selection problems
    By innerhippy in forum Qt Programming
    Replies: 5
    Last Post: 19th December 2008, 05:48
  4. QTableView, QSqlTableModel - data disappears
    By msh in forum Qt Programming
    Replies: 1
    Last Post: 15th November 2008, 11:50
  5. QTableView and QSqlTableModel problem
    By Misenko in forum Qt Programming
    Replies: 5
    Last Post: 19th August 2008, 21: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
  •  
Qt is a trademark of The Qt Company.