How can I unset or change a relation on a QSqlRelationalTableModel?
-
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".
-
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
-
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.