Hi-
I'm looking to create a table with checkable items based off a
dictionary using the QStandardItemModel class, what is the best practice
to do this? I've looked at using the class directly and it seemed
cumbersome to add the data to the table and I couldn't get data to
display at all when I subclassed.
class MyTableModel(QStandardItemModel):
def __init__(self, datain, headerdata, parent=None, *args):
""" datain: a list of lists headerdata: a list of strings """
QStandardItemModel.__init__(self, 5, 6)
self.arraydata = datain
self.headerdata = headerdata
def rowCount(self, parent):
return len(self.arraydata)
def columnCount(self, parent):
return len(self.arraydata[0])
def data(self, index, role):
if not index.isValid():
return QVariant()
elif role != Qt.DisplayRole:
return QVariant()
return QVariant(self.arraydata[index.row()][index.column()])
def headerData(self, col, orientation, role):
if orientation == Qt.Horizontal and role == Qt.DisplayRole:
return QVariant(self.headerdata[col])
return QVariant()
thanks
_______________________________________________
PyQt mailing list [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt