0

I am using a QtableView to display data from a QSqlRelationalTableModel which seems to work fine, however when I use self.motormodel.setRelation(1, QSqlRelation('Instruments', "Asset Tag","Description" )) self.ui.motorTableView.setItemDelegate(QSqlRelationalDelegate(self.ui.motorTableView))

to create a QSqlRelationalDelegate on the view and I try and sort the columns using the header of a column in the tableView the table doesn't refresh and I lose the model data in the view.

If I comment out the self.motormodel.setRelation(1, QSqlRelation('Instruments', "Asset Tag","Description" )) then it works as expected and the sort works.

Does anyone know what I am missing?

2
  • Please provide enough code so others can better understand or reproduce the problem. Commented Aug 27, 2021 at 23:42
  • why are you creating a relationship on the view? it is in the model if ever. Is assettag the foreign key? Commented Dec 3, 2021 at 8:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.