[Qt-interest] QDataWidgetMapper and QSqlRelationalTableModel without some column
jjDaNiMoTh
jjdanimoth at gmail.com
Tue Feb 23 11:57:20 CET 2010
Hello list,
sorry for the big big subject.
I have the following problem with a QDataWidgetMapper and
QSqlRelationalTableModel, using PostgreSQL as dbms:
In my software, I have a QTableView that displays data from a
QSqlRelationalTableModel. If the user want to edit data, he
double-click on the row, and the software will display a dialogBox
with label (for header) and QTextEdit / QComboBox as editing field.
The user do the necessary modifications, and then they are pushed back
to the QTableView after pressing the "Ok" button.
It is really simple to setup (there are many many example) and in this
case, it works fine.
But if I remove a column from the model (like, model.removeColumn(0)),
when the user click the "Ok" button, a magic error appears:
QSqlQuery::value: not positioned on a valid record
and the data aren't pushed back in to the model, or if they are
pushed, saving the model (with model.submitAll()) return the old data
back into the view.
I know that without code, all my post is useless, so I've coded an
example applications [1] that do above operations on a test database
(you need to copy/paste the SQL command to create and populate
database into psql) and that here (Qt 4.6.2, OS X) produce the above
error. Sorry for the poor coding, I know there are many potential
bugs. Do the basic operation (like doubleclick, edit and click the
buttons) to save your PC from many segfaults :)
Try commenting / uncommenting the line mainwindow.cpp:34 .
I don't know if with other Sql driver (like sqlite) it works or it
give same error. I will try in the afternoon.
Am I missing something?
[1] http://www.gigasize.com/get.php?d=0vt1mpc8mcb
--
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
More information about the Qt-interest-old
mailing list