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
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    [email protected]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

Reply via email to