[PyQt] Maintaining index after sort

Andreas Pakulat apaku at gmx.de
Mon May 30 19:54:33 BST 2011


On 29.05.11 15:06:17, Marc Rossi wrote:
> Thanks for the reply.  There must be some core concept of Qt/Model-View
> programming I am just missing.
> 
> Makes sense that I can store the data keyed by symbol in the model and
> update it that way, but I thought I had to emit a dataChanged signal for the
> view to update as shown below:
> 
>     self.emit(SIGNAL("dataChanged(QModelIndex,QModelIndex)"),
> self.index(index.row(), COL1), self.index(index.row(), COL5))
> 
> Doing it this way required me to have the index for the column I wanted
> refreshed.   I see there is a 'match()' function in the QAbstractItemModel
> class but when I tried that (calling match for every update) things were
> ridiculously slow.

Hmm, I don't have that much experience with sorting without a proxy
model between the real one and the view, but if the model does not get
notified about changes in its indexes then that sounds like a there's a
bug somewhere.

Andreas



More information about the PyQt mailing list