I am new to Qt and SQL, so please bear with me. I have been able to connect to a database and view it through the use of QSqlRelationalTableModel and QTableView. I am now trying to hook up code to a button for inserting a new row, or deleting a selected row. I have tested my SQL statements with the SQLite command line interpreter for both inserting and deleting. When I execute the QSqlQuery to do the same thing as what I typed on the command line, I see the wrong behavior. For example, when I want to "INSERT INTO...", not one row but 2 rows are inserted!
The same problem exists when I go to delete a row, two rows are deleted. I've connected to the QTableView's clicked() signal, which passes a QModelIndex so that I can grab the index's row and perform a delete on that row. I hope I am correct when I say that I've noticed the rows are ORDERED BY SQLite's ROWID. So, I'm able to delete a specific ROWID based on the row index returned by the clicked() signal.
Again, I've tested my SQL commands in the interpreter and they work great. When I use the Qt SQL code, extra inserts and deletes occur. Is this a bug?
I would be open to using a different database implementation, but I don't know how to use those and I'm short on time. As a side note, how does one create a new database without using something like the SQLite command line tool? Can you write Qt code to create a new DB?
Thanks!
Bookmarks