PDA

View Full Version : wait for method to complete?



jtdavidson
18th July 2010, 04:59
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

tbscope
18th July 2010, 07:16
submitAll() returns true or false based on success. You can take advantage of this.


if (submitAll())
// requery and check what has been added (you can do that before adding too)
else
// some error occured

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