PDA

View Full Version : Asynchronous database operations



sajmplus
6th December 2015, 15:59
What is a proper way to operate on QSqlDatabase asynchronously?

I know method with Worker class and QObject::moveToThread function, but in case when I work with QSqlTableModel i think it could be hard to use.

How can I insert/update/remove from QSqlTableModel asynchronously? Is there any signals when data transfer (model->database and database->model) which I can use to inform user that operation is in progress (e.g. open progress dialog when start executing and close on complete, use message box if error).

anda_skoa
6th December 2015, 17:14
If you need threaded access to a database while at the same time having a model, then you will need your own table model that does the threaded database access internally.

Cheers,
_

sajmplus
10th December 2015, 10:25
If you need threaded access to a database while at the same time having a model, then you will need your own table model that does the threaded database access internally.


How can I achieve it? Which methods of QSqlTableModel should I overload?

anda_skoa
10th December 2015, 22:09
You would start with subclassing QAbstractTableModel and implementing columnCount(), rowCount() and data().

Cheers,
_