Results 1 to 2 of 2

Thread: Model/View programming support for database locks!

  1. #1
    Join Date
    Sep 2008
    Location
    Portugal
    Posts
    171
    Thanks
    57
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Model/View programming support for database locks!

    Hi
    When i use Model/View programming, is there a way to lock a register in the database when it is being edited on the view?
    I tested with two instances of the same program, accessing the same database. On the first, while editing a row, i remove it in the other. Then i loose consistance until i update the model.
    And what about transactions! Does it support?

  2. #2
    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: Model/View programming support for database locks!

    Quote Originally Posted by graciano View Post
    When i use Model/View programming, is there a way to lock a register in the database when it is being edited on the view?
    No. Lock on read is general a bad thing with a view that might sit open forever.
    And what about transactions! Does it support?
    QSqlTableModel does not explicitly create a transaction itself.

    The model inserts/updates/delete will be part of a database transaction if you create one with QSqlDatabase::transaction() on the database connection. You then call QSqlDatabase::commit() or rollback() as required. This mechanism would work best with OnManualSubmit where you start the transaction, call QSqlTableModel::submitAll(), and commit() or rollback() based on the success of submitAll(). Read the note on SqlTableModel::submitAll() about failures.

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

    graciano (12th December 2013)

Similar Threads

  1. about model/view programming
    By Pang in forum Qt Programming
    Replies: 3
    Last Post: 13th December 2006, 08:42
  2. MODEL/VIEW programming and TABLES
    By newbie in forum Qt Programming
    Replies: 5
    Last Post: 27th August 2006, 21:26
  3. Model - View Programming doubt.
    By munna in forum Qt Programming
    Replies: 4
    Last Post: 28th April 2006, 13:01
  4. MODEL/VIEW programming
    By mira in forum Newbie
    Replies: 3
    Last Post: 21st April 2006, 11:19
  5. Model/View Programming -- Signals
    By KjellKod in forum Qt Programming
    Replies: 17
    Last Post: 7th February 2006, 16:36

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.