[PyQt] Problem with implementation of dummy (no-op) proxy model

Dan Halbert halbert at halwitz.org
Thu Oct 28 14:08:16 BST 2010


On Thursday, October 28, 2010 8:28am, "Hans Meine" <meine at informatik.uni-hamburg.de> said:
> I am about to give up now, but first I want to post my current code again; I
> added some assertions which show an interesting fact which I have no
> explanation for:  One assertion fails, since I am getting a QModelIndex of my
> proxy model in which internalPointer does *not* contain a QModelIndex of the
> proxied model anymore, but NULL/None.

There have been some related discussions on the mailing list you might take a look at, for instance: http://www.riverbankcomputing.com/pipermail/pyqt/2006-July/thread.html#13786. Google [ site:riverbankcomputing.com internalpointer ] to find some more.

It might also be interesting to rewrite your Python code in the corresponding C++ and see if you see similar behavior.

In my limited use of proxy models, I have not found it useful to store QModelIndex objects in the internalPointer(). Instead I have created some "proxy data objects" that reference the actual data model (which is Qt-independent). I subclassed QSortFilterProxyModel since it implemented a bunch of stuff I would otherwise have had to reimplement.

I would also note that your proxy model did not implement mapToSource() and mapFromSource() as required, though I don't think they would be called in the simple example you posted.

Dan






More information about the PyQt mailing list