[Qt-interest] QTableView doesn't use delegate

Timothy Reaves treaves at silverfieldstech.com
Fri Dec 11 16:41:25 CET 2009


I have a QTableView, a QSqlTableModel, and an QItemDelegate subclass. I create my model, and set that on the table view. I create my delegate, and set that on the table view.

QSqlTableModel *tableModel = new QSqlTableModel(0, db);
tableModel->setTable("data_table");
tableModel->select();
ui->tableView->setModel(tableModel);
ui->tableView->setItemDelegate(new MyTableDelegate(ui->tableView));


When my window display, the table does display the data from the SQL table. However, not a single method in my delegate is called. I implement
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;

and have a log statement as the first line in each method. None gets hit.

Is there something about the combination of thee three classes that make them incompatible? Am I missing something?

Thanks! 





More information about the Qt-interest-old mailing list