[PyQt] Using QModelIndex.internalPointer
giacomo.alzetta at gmail.com
Sat Dec 5 19:05:48 GMT 2009
David Boddie wrote:
> Then this would indicate that there may be a bug with the createIndex()
> wrapper in PyQt, though it would be difficult to know exactly what the
> cause is without a test case or minimal example that demonstrates the
> Which versions of SIP and PyQt are you using?
I'm using PyQt 4.6 and sip 4.9.1-snapshot-20091015
I think it's strange for PyQt to have a bug in such a crucial method.
Anyway I'll try to post some code when I have time...
Right now the only thing I can show to explain better what I meant is this:
I have a class that's something like this:
self._data = data
In my index method (of the model) I do something like this:
if not parent.isValid():
parent_row = parent.row()
obj = self.manager.get_item(parent_row,row)
And my parent method looks like this:
if not index.isValid():
obj = index.internalPointer()
if obj is None:
parent_row = self.manager.index(obj)
The exception is raised when "self.manager.index" is called;
because the manager class to obtain the index of the object calls "data",
and this call raise an AttributeError like this:
AttributeError: "DataContainer" object has no attribute "_data"
Like if the object wasn't initialized.
I think I'll try to rewrite it following exactly the "simpletreemodel" to
check if it is a bug or if I'm doing something wrong...
Thank you for your attention David.
View this message in context: http://old.nabble.com/Using-QModelIndex.internalPointer-tp26635941p26658308.html
Sent from the PyQt mailing list archive at Nabble.com.
More information about the PyQt