Hi Vláďa,

2011/3/3 Vláďa <[email protected]>
> I implemented the behavior that the model returns None if the UI requests 
> items that do not exist. But as I expected I only got rid of the errors, but 
> the incorrect behavior (not all items or empty items are shown) remains. I 
> was hoping that Qt 4.7.2 might fix the problem, but it didn't change anything.
>
> I do believe it is not bug in my code, but there is something wrong in either 
> PySide or Qt/QML. Could someone confirm it?

Can you provide a minimal example that demonstrates your problem? If
it's a bug, please file it at bugs.pyside.org (yay for the new domain
name ;). The way I do it in gPodder currently is simply a list model
with a list of QObject subclasses:

http://repo.or.cz/w/gpodder.git/blob/refs/heads/tres:/src/gpodder/qmlui/__init__.py#l133

The data() function is defined like this:

 154     def data(self, index, role):
 155         if index.isValid():
 156             if role == 0:
 157                 return self.get_object(index)
 158             elif role == 1:
 159                 return self.get_object(index).qsection
 160         return None

And get_object() is also similarly trivial:

 148     def get_object(self, index):
 149         return self._objects[index.row()]

Here, self._objects is a simple python list that contains my objects.
If the list changes, I simply replace the _objects contents and call
reset() - it would obviously be more performant if you did
fine-grained changes to that list. That said, it does not happen often
for my use case, and as the QObjects in the list have notifyable
properties, and my list delegate uses these properties, the list can
be updated (by changing the properties on the objects) without the
abstract list model knowing about it.

HTH :)

Thomas
_______________________________________________
PySide mailing list
[email protected]
http://lists.openbossa.org/listinfo/pyside

Reply via email to