[Qt-interest] QSortFilterProxyModel over a QSqlRelationalTableModel
mario
dodiesis at gmail.com
Fri Jan 30 17:16:00 CET 2009
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
More information about the Qt-interest-old
mailing list