Hi,

I just installed PySide 1.0 final and the problem is gone. This makes me happy for two reasons:

1) It's now fixed
2) The mistake wasn't at my side ;-)

Many thanks to all PySide developers for your great work and support.

Vláďa

Dne 4.3.2011 17:49, Vláďa napsal(a):
Hi Thomas,

Please see the example I attached. It's also updated at http://www.mediafire.com/file/ziba471shfp2hak/llistmodel_test.7z (main.py and List.qml are the important files, I split the qml to multiple files to make the important part as simple as possible).

I believe my approach is very similar to your's. What i did is simply to remove all items from the model and then I add new ones. The items are added correctly, but the associated ListView show it incorrectly until it is refreshed.

Please test it and let me know if you see any problems in my code. Thanks a lot for your help.

Vláďa

Dne 4.3.2011 10:50, Thomas Perl napsal(a):
Hi Vláďa,

2011/3/3 Vláďa<vlad...@atlas.cz>
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
PySide@lists.openbossa.org
http://lists.openbossa.org/listinfo/pyside
_______________________________________________
PySide mailing list
PySide@lists.openbossa.org
http://lists.openbossa.org/listinfo/pyside

Reply via email to