K
K
Kurum2019-01-05 15:25:15
Python
Kurum, 2019-01-05 15:25:15

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
c2ef4d5fc32e.pnghttps://d.radikal.ru/d02/1901/47/c2ef4d5fc32e.png
ec2922e05df3.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alexapod, 2019-01-05
@alexapod

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

And I've never seen anything like it. Those. UIC file is always separate for me. Easier and in editing and then to give to the user.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question