PDA

View Full Version : Problems with databases in QT.



sweetnattaly
11th September 2013, 18:41
(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!

ChrisW67
13th September 2013, 22:54
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:


QAbstractItemModel::endInsertRows: Invalid index ( 1 , 0 ) in model QSqlTableModel(0xe1af70)
QAbstractItemModel::endInsertRows: Invalid index ( 1 , 2 ) in model QSqlTableModel(0xe1af70)
QAbstractItemModel::endInsertRows: Invalid index ( 1 , 3 ) in model QSqlTableModel(0xe1af70)

if I try to force the new track (at row 0 not 1) to commit by adding another track.