Hello,

The problem can be solved as shown below.

It seems the linux 32 bit implementation gets confused in createIndex(row, column, a) when a is not an integer but a long. With small values of a (10, 100, 1000), the indexId() method returns the supplied value.

The solution is to call createIndex(row, column, a) with a being a python object and not its id. The indexId() method can be masked with a 32 bit mask if it returns a negative value. I have only found that misbehavior under linux 32bit. Windows XP and linux 64-bit behave properly.

Thanks for your time,

Armando

import PyQt4.Qt as qt
import random
import sys

mask = 0xFFFFFFFF

class Model(qt.QAbstractItemModel):
 def index(self, row, column, parent):
     a=[random.random()]
     index =  self.createIndex(row, column, a)
     print "Next two values should be the same"
     returned = index.internalId()
     if returned < 0:
         returned = returned & mask
     print "indexInternalId = ", returned
     print "id(a) = ", id(a)
     print "Forcing to be the same with a 32 bit mask"
     print "indexInternalId = ", index.internalId() & mask
     print "id(a) = ", id(a) & mask
     return index

if __name__ == "__main__":
 app = qt.QApplication([])
 w = Model()
 w.index(0,0,None)


_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to