How can I unset or change a relation on a QSqlRelationalTableModel?
-
wrote on 9 Dec 2010, 15:25 last edited by
I can use QSqlRelationalTableModel::setRelation (int column, const QSqlRelation & relation) to set a relationship.
However I want to be able to change the column that is displayed from the "foreign" table.
Calling setRelation a second time with a different QSqlRelation doesn't seem to have an effect, and there appears to be no "unsetRelation".
-
wrote on 9 Dec 2010, 20:50 last edited by
To unset the relation I would try:
@model->setRelation(column, QSqlRelation());@For the other issue you might want to look into "edit strategies":http://doc.trolltech.com/latest/qsqltablemodel.html#EditStrategy-enum
-
wrote on 9 Dec 2010, 21:12 last edited by
After much guessing and testing I discovered I needed to call
@QSqlRelationalTableModel::setModel()@
after I set or change the relationship.
@QTableView::setItemDelegate()@ also now works properly.
1/3