[PyQt] Problem with implementation of dummy (no-op) proxy model
meine at informatik.uni-hamburg.de
Thu Oct 28 15:40:59 BST 2010
Op den Dunnersdag 28 Oktober 2010 Klock 15:08:16 hett Dan Halbert schreven:
> On Thursday, October 28, 2010 8:28am, "Hans Meine" <meine at informatik.uni-
> > 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:
> 86. Google [ site:riverbankcomputing.com internalpointer ] to find some
Thanks. They're related, and although I could not find a single posting with
a good explanation, I think I finally understood what's going on. I will
explain it in a separate posting in a minute.
> It might also be interesting to rewrite your Python code in the
> corresponding C++ and see if you see similar behavior.
Yes, I would get the exact same behaviour, only that I would already notice
that I am doing something wrong while coding, since I would not be tempted to
rely on proper reference counting.
> In my limited use of proxy models, I have not found it useful to store
> QModelIndex objects in the internalPointer().
No, it's not possible.
> Instead I have created some
> "proxy data objects" that reference the actual data model (which is
The crucial part is that these "proxy data object" need to be kept alive. The
kind of object does not really matter.
> I subclassed QSortFilterProxyModel since it implemented a
> bunch of stuff I would otherwise have had to reimplement.
I don't think that would help me in any way, and I have had bad experiences
with deriving from too specialized classes in PyQt.
> 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.
That's because I do not derive from QAbstractProxyModel, but just from a
Thanks for the additional pointers,
More information about the PyQt