[PyKDE] QAbstractItemModel 64 bit problem

Jeremy Sanders jeremy at jeremysanders.net
Tue Sep 26 11:01:01 BST 2006


Hi -

I have some code which doesn't appear to work on x86_64 python, but does on 
i386

def MyModel(qt4.QAbstractItemModel):

     ...

     def __init__(self, ...):
         self.objdict = {}
         ...

     def index(self, row, column, parent):
         """Construct an index for a child of parent."""

         if not parent.isValid():
             parentobj = None
         else:
             parentobj = self.objdict[parent.internalId()]

         children = self._getChildren(parentobj)

         c = children[row]
         cid = id(c)
         self.objdict[cid] = c

         return self.createIndex(row, column, cid)

The python Ids appear to be large integer values, e.g. 183006915920, but when 
they are returned from internalId(), then they come back as negative values 
e.g., -1676677808L, which don't even appear to match the bit pattern of the 
original value.

I seem to remember the old example simpletreemodel.py used internalId, but does 
no long. Maybe this could reproduce the problem (I don't have a copy, and old 
PyQt versions aren't archived).

Jeremy




More information about the PyQt mailing list