[Qt-interest] QSortFilterProxyModel over a QSqlRelationalTableModel
Scott Aron Bloom
Scott.Bloom at sabgroup.com
Fri Jan 30 17:59:33 CET 2009
Looks like a bug in the createEditor...
Should check for a source model...
I would file it with trolltech, with the fix.. Then create your own
derived delegate with the 2 or 3 lines of code fix.
Scott
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of mario
> Sent: 2009-01-30 08:16
> To: qt-interest at trolltech.com
> Subject: [Qt-interest] QSortFilterProxyModel over a
> QSqlRelationalTableModel
>
> Hi all.
>
> Problem: I have QSqlRelationalTableModel to show in a QTableView.
> I put a QSortFilterProxyModel between the sqlmodel and the view... It
> works but I loose the "automatic combobox features": when I
> doubleclick on the reliation cell, a normal editor appears.
>
> No matter if I write or not:
>
> tableView->setItemDelegate( new QSqlRelationalDelegate(tableView) );
>
> This is the source code of QSqlRelationalDelegate
>
> [...]
> QWidget *createEditor(QWidget *parent,
> const QStyleOptionViewItem &option,
> const QModelIndex &index) const
> {
> const QSqlRelationalTableModel *sqlModel = qobject_cast<const
> QSqlRelationalTableModel *>(index.model());
> QSqlTableModel *childModel = sqlModel ?
> sqlModel->relationModel(index.column()) : 0;
> if (!childModel)
> return QItemDelegate::createEditor(parent, option, index);
>
> [...]
>
> Obviously the cast fails, and the "QItemDelegate::createEditor(parent,
> option, index);" is called.
>
> How can I do?
> The only solution I see is to paste the code from
> QSqlRelationalDelegate in my own delegate... (I know... 10 lines..
> but.. seems bad)
>
> Tnx
>
>
> --
> Mario Signorino | www.sgrunt.net
> _______________________________________________
> 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