[SOLVED] How can I access foreign keys/records in QSqlRelationalTableModel/QItemDelegate
-
I am using QSqlRelationalTableModel::setRelation to display data from a foreign table in a tableview. The delegate examples explain how to change which foreign record is displayed (using combo boxes) but not how to change the actual foreign record itself. I have a custom delegate setup and can createEditor and setEditorData but I cannot figure how to setData since in my delegate, I only seem to have access to the displayable data and have no access to the foreign record for editing purposes. If I could access the foreign key in my delegate, I could move forward. Does anyone know how to do this? Or is there a better way?
-
I figured out a solution. Create another QSqlRelationalTableModel without relations set and use it to grab the foreign record for editing purposes.