[Qt-interest] QSqlRelation and order of items in combo box

Harry Sfougaris hsfougaris at gmail.com
Fri Apr 23 09:46:56 CEST 2010


Hi all,

When using an QSqlRelation, is there a way to specify the order of the items
in the detail table?
If I have
QSqlRelationalTableModel   *mMdl = new QSqlRelationalTableModel(this);
mMdl->setTable("masterTbl");
mMdl->setRelation(master_fld1, QSqlRelation("detailTbl", "id", "descr"));
and then
ui->tblView->setItemDelegate(new QSqlRelationalDelegate(this));

I get a combo box in ui->tblView (which is a QTableView) for the field
master_fld1.
However, I would like to change the sort order of the items, as it is
currently undefined (there is no ORDER BY section in the SQL that is sent to
the server for detailTbl).
Can I either specify somehow an ORDER BY for QSqlRelation, or change the
sort order of the items in the combo box?

Thank  you,
Harry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100423/eeeff24c/attachment.html 


More information about the Qt-interest-old mailing list