[PyQt] Item.data() and python dictionary

IT it at geolab.org.uk
Fri Jun 12 16:48:36 BST 2009


newbie question. I've searched for this but still not sure how to proceed.

What I want to do it store a dict in item data eg

job = {'job_no': 345, 'status': 20, 'foo': 10}

si = QtGui.QStandardItem(job['job_no])
si.setData( QtCore.QVariant( job ) )

Problem is how do I convert it back, eg on a click event..

    def on_table_clicked(self, modelIndex):
        print "on_table_clicked row/col", modelIndex.row(), 
modelIndex.column()
        data = self.model.itemFromIndex( modelIndex ).data()

        print data   # .toPythonDictionary()

kind regards

Pete


More information about the PyQt mailing list