[PyQt] Model/View programming

David Boddie david at boddie.org.uk
Tue Sep 22 01:37:33 BST 2009


On Mon, 21 Sep 2009 13:20:33 +0200, Lukas Hetzenecker wrote:

> When I get a reply from the phone (some items) I don't know how to get the
> parent QModelIndex for the directory (internal pointer). Currently I store
> the index in my internal class and update it on every createIndex call - is
> there any better solution?

You probably shouldn't store the actual QModelIndex objects. From memory
(and bearing in mind that it's very late here) there's a way to pass in a
Python object when your model creates indexes and get them back again later.
Ideally, this is what you should do.

> But this doesn't even work, I can't append the child item (it isn't shown
> in the view). Can anybody look at my example and show me the right way?

I tried running your test case and found that the view displayed various
items in an incomplete way - when you see trailing branches, it's a sure
sign that something isn't quite right.

I'll try and take a look at this tomorrow unless someone manages to help
you out in the meantime.

David


More information about the PyQt mailing list