Results 1 to 2 of 2

Thread: Problems with databases in QT.

  1. #1
    Join Date
    Sep 2013
    Qt products

    Default Problems with databases in QT.

    (Sorry i dont speak english, im using google translator)

    I am testing a program of the book "C + + programming with QT" and I have problems when i try to add a song to a cd, the changes are not saved, do not understand why, changes in the database are not saved. I hope your help, thank you very much!
    Attached Files Attached Files

  2. #2
    Join Date
    Mar 2009
    Brisbane, Australia
    Thanked 1,592 Times in 1,520 Posts
    Qt products
    Qt4 Qt5
    Unix/X11 Windows
    Wiki edits

    Default Re: Problems with databases in QT.

    In your code the trackModel->editStrategy() is QSqlTableModel::OnRowChange. Changes are not written to the database until you select a different row (or call submitAll()). If there is no other row to select then the data is not committed. The row header for the new row has "*" until it is committed.

    I also see run time warnings:
    Qt Code:
    1. QAbstractItemModel::endInsertRows: Invalid index ( 1 , 0 ) in model QSqlTableModel(0xe1af70)
    2. QAbstractItemModel::endInsertRows: Invalid index ( 1 , 2 ) in model QSqlTableModel(0xe1af70)
    3. QAbstractItemModel::endInsertRows: Invalid index ( 1 , 3 ) in model QSqlTableModel(0xe1af70)
    To copy to clipboard, switch view to plain text mode 
    if I try to force the new track (at row 0 not 1) to commit by adding another track.

Similar Threads

  1. Databases?
    By Atomic_Sheep in forum Newbie
    Replies: 2
    Last Post: 7th May 2012, 13:15
  2. Using MySQL databases?
    By bmn in forum Qt Programming
    Replies: 1
    Last Post: 17th December 2010, 19:43
  3. still some problems on update databases using QDataWidgetMapper
    By xiongxiongchuan in forum Qt Programming
    Replies: 7
    Last Post: 8th July 2010, 18:39
  4. Qt and databases
    By gt.beta2 in forum Newbie
    Replies: 6
    Last Post: 18th February 2009, 08:39
  5. dictionary databases
    By rishiraj in forum Newbie
    Replies: 1
    Last Post: 5th January 2009, 08:30


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.