Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Problem with QSqlTableModel writing data to MySql database

Problem with QSqlTableModel writing data to MySql database

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 2.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tuanster
    wrote on 11 Feb 2011, 02:44 last edited by
    #1

    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.

    Thanks,

    TP

    1 Reply Last reply
    0
    • C Offline
      C Offline
      changli85
      wrote on 11 Nov 2011, 10:06 last edited by
      #2

      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 !

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved