Doing the SQL task in another thread
I have read similar issues with this topic, but the solutions people post to deal with it don't make use of neither the SQL high-level interface provided by Qt (QSqlTableModel and such) nor the Model/View programming.
Since this two combined offer a very fast way to implement an app, it's easy to just use this approach rather than doing my own interface from "scratch".
So I came up with this idea to keep using this two features and to make them suitable for multithreading programming. I will create my own QSqlTableModel & QSqlRelationalTableModel and re-implement those method needed for Model/View programming to work. The re-implemented methods will only call QMetaObject::invokeMethod() with Qt::AutoConnection. This way I can have the models and the QSqlDatabase instance in one thread and the view with the rest of the GUI in another one.
My questions are:
- Is there a better solution?
- Is my solution viable?
- Which problem may I encounter with this approach?
I do appreciate any feedback.