[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyKDE] viewing a QStandardItemModel
From:       alexander krohn <ak () e-dict ! net>
Date:       2007-02-21 17:43:03
Message-ID: 45DC84A7.208 () e-dict ! net
[Download RAW message or body]

hi.

i have a column in a QStandardItemModel filled with a numerical value. now i 
want to show this in a QTableView in a different way, the value represents some 
kind of state, so i don't want to see a number, but a string like "ok" or "not ok".

although i think that is an aspect of the view, i thought that the roles can do 
this, so i set the numerical value for the Qt.EditRole and the string for 
Qt.DisplayRole.

so much for the theory, it doesn't work. so attached code shows twice the string 
"one" and not 1 and "one" as i would expect.

any ideas?

alexander

["standarditemmodel.py" (text/x-python)]

from PyQt4 import QtCore, QtGui

if __name__ == '__main__':
    m = QtGui.QStandardItemModel(1, 1)
    mi = m.index(0, 0)
    m.setData(mi, QtCore.QVariant(1), QtCore.Qt.EditRole)
    m.setData(mi, QtCore.QVariant("one"), QtCore.Qt.DisplayRole)

    print mi.data(QtCore.Qt.DisplayRole).toString()
    print mi.data(QtCore.Qt.EditRole).toString()


_______________________________________________
PyKDE mailing list    PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic