Answer the question
In order to leave comments, you need to log in
Pyqt4 | Why do indexes break in QTableWidget after sorting?
There is a QTableWidget table with data.
By clicking on a table row, I get the row index, and the row data appears in the form fields. If I sort by clicking on the column headers, then by clicking on the table, the row indexes will be left, and the wrong data is inserted into the fields, respectively.
I read that the following method helps in such a situation:
before inserting a row into the table, do "self.table.setSortingEnabled(False)", and after "self.table.setSortingEnabled(True)". However, in this case, sorting does not work at all.
See the code and database here
Screenshots
https://d.radikal.ru/d02/1901/47/c2ef4d5fc32e.png
Answer the question
In order to leave comments, you need to log in
To be honest, I never carry all my eggs in one basket.
from PyQt4 import QtGui, QtCore, uic
from PyQt4 import QtGui, QtCore as qt
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question