[Qt-interest] QDataWidgetMapper and QSqlRelationalTableModelwithout some column

Scott Aron Bloom Scott.Bloom at sabgroup.com
Tue Feb 23 17:43:25 CET 2010


Rather than removing the column from the model, hide the column on the
view.

Scott

-----Original Message-----
From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of jjDaNiMoTh
Sent: Tuesday, February 23, 2010 02:57
To: QT Mailing LIST
Subject: [Qt-interest] QDataWidgetMapper and
QSqlRelationalTableModelwithout some column

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
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list