pythonpyqtpyqt5qsqlquerymodelqsqlrelationaltablemodel

QSqlRelationalTableModel with OnManualSubmit


I set the model of a view like this:

model = QSqlRelationalTableModel()
model.setEditStrategy(QSqlTableModel.OnManualSubmit)
model.setTable("VoucherPos")
model.setFilter("VoucherKey='" + str(parent_id) + "'")

model.setRelation(10, QSqlRelation("IO", "IOKey", "IOText"))

self.tblSubTable.setItemDelegate(QSqlRelationalDelegate())
model.select()
self.tblSubTable.setModel(model)

But after editing column 10 in the tableview, there will be shown the id-value (IOKey). Before editing is the right related value ("IOText") shown.

If I remove the line with the "setEditStrategy" everything works ok, but I want to have an EditStrategy with "OnManualSubmit".

Thanks!


Solution

  • I solved the problem. In my original code I used a subclassed QSqlRelationalTableModel where I set the alignment for some columns (and column 10 too). When I use the original QSqlRelationalTableModel-class everything works fine.