Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Storing Changes from TableView to Model to SQLITE Database
Forum Updated to NodeBB v4.3 + New Features

Storing Changes from TableView to Model to SQLITE Database

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 926 Views 1 Watching
  • 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.
  • R Offline
    R Offline
    rizoritis
    wrote on last edited by
    #1

    Hello,

    After reading the Qt documentation and playing around with some code I am still a bit confused as to what each part of my code that stores changes to my database actually does. I have the following code:

    @ database->pointsTableModel->database().transaction();
    if(database->pointsTableModel->submitAll())
    {
    database->pointsTableModel->database().commit();
    }@

    I am unsure as to whether all three of these calls are necessary to save the changes to my persistent database. In leyman's terms what exactly does transaction() do? Instead of calling submitAll() can I just go straight to commit()?

    Thanks,

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Seba84
      wrote on last edited by
      #2

      You really should not need all of these calls. One of these should be sufficient:
      @QSqlTableModel::submit();
      QSqlTableModel::submitAll()@

      The "QSqlTableModel":http://qt-project.org/doc/qt-5.0/qtsql/qsqltablemodel.html should be already pointing to your database.

      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