qt-interest@trolltech.com
[Top] [All Lists]

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

Subject: Re: [Qt-interest] QSqlRelation and order of items in combo box
From: Harry Sfougaris
Date: Fri, 23 Apr 2010 11:26:56 +0300
Well, it is an option, but as I have numerous lookup tables it would be messy.
Also, with MSSQL you have to use the weird 'select top 100 percent *' syntax if you want to use ORDER BY....

But it is a good alternative, thank you for reminding me of it...

Harry


On Fri, Apr 23, 2010 at 11:13 AM, Andre Somers <andre@xxxxxxxxxxxxxxxx> wrote:
On 23-4-2010 9:46, Harry Sfougaris wrote:
> 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
>
Perhaps as an alternative, you could provide a view in your database
that is already sorted, and use that as the source for your items
instead of using the underlying table directly?

André

_______________________________________________
Qt-interest mailing list
Qt-interest@xxxxxxxxxxxxx
http://lists.trolltech.com/mailman/listinfo/qt-interest

_______________________________________________
Qt-interest mailing list
Qt-interest@xxxxxxxxxxxxx
http://lists.trolltech.com/mailman/listinfo/qt-interest
<Prev in Thread] Current Thread [Next in Thread>