Results 1 to 2 of 2

Thread: wait for method to complete?

  1. #1
    Join Date
    Jul 2010
    Posts
    11
    Qt products
    Qt4
    Platforms
    MacOS X

    Default wait for method to complete?

    I have a QSqlTableModel.submitAll() that submits hundreds of rows to a database at once. All, some or none of the rows maybe be accepted by the database, due to the database's rules governing the uniqueness of the rows of data.
    The next line of my code then queries the database, to see what was accepted and report the success or failure back to the user.
    The trouble is, the database seems to be still processing the submitAll() when the query is made, and often the query returns an incomplete or empty list of changes when indeed hundreds of rows have been added to the table.
    How do I make the execution of the query wait for submitAll() to finish? Or, how else might I think about this function? Obviously I could just add a fixed delay, but I want to go about this the right way.

    thanks in advance

    John
    Learning, one problem at a time.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: wait for method to complete?

    submitAll() returns true or false based on success. You can take advantage of this.

    Qt Code:
    1. if (submitAll())
    2. // requery and check what has been added (you can do that before adding too)
    3. else
    4. // some error occured
    To copy to clipboard, switch view to plain text mode 

    Note though that this will block till all the data is added.

Similar Threads

  1. complete tablewidget
    By tux-world in forum Newbie
    Replies: 3
    Last Post: 11th March 2010, 02:07
  2. Complete newbie with programming and Qt
    By Jacob in forum Newbie
    Replies: 1
    Last Post: 6th March 2010, 06:26
  3. Update complete notification?
    By dingetje in forum Qt Programming
    Replies: 0
    Last Post: 27th May 2009, 11:07
  4. Tableview complete sizehint
    By skuda in forum Qt Programming
    Replies: 0
    Last Post: 5th March 2009, 10:33

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.