Problem with QSqlTableModel writing data to MySql database
I'm writing a QML plugin in Qt to return data from both MySql and Sqlite database. The feature that I'm trying to implement is the ability for the user in QML to modify data in the model and then write it back to the database. I have a SqlListModel that has an instance of QSqlTableModel. I have two classes, MySqlDatabase and SqliteDatabase, which are derived from a common database base class. When I try to use Sqlite database with my SqlListModel, it seems to be working. I can select, update, and remove existing data from the model and upon a submitAll call, all the changed data are written back to the database. It's all fine and dandy until I try to use SqlListModel with MySqlDatabase. I can perform select and insert new records into the model and then it can write it back to the database. The issue is with updating/removing existing data in the database. I can't seem to figure out why or a way to get around this issue.
Any tip is very appreciated.
hi ,can you tell me how do you select and insert new records into the model and write it back to the database ,can you give me some good idea, and can you show me your codes. thanks !