Hi,
I cannot get any data to be shown in my QTableView and wonder now if
something could be wrong with returning the QVariants(), as someone on
Daniweb said this is not necessary anymore after PyQt 4.6. Also I read the
PyQt documentation about QVariant, but have not gotten any further.
Without giving you the whole nine yards, can anyone spot any beginners error
below? The data itself is loaded into a list (self.uncertainties) of
Uncertainty() objects. An Uncertainty() has 22 attributes that I want to
show in a table. I already have a working system using QTableWidgets, so the
underlying data structures are loaded into memory and in good condition.:
(name, description, valuetype, active, defaultvalue, uuid, digits,
distribution, expectation, expression, gridsize, levels, lowerlimit,
priorweight, replacestring, standarddeviation, startvalue, stepsize,
targetfiles, category, frequency, upperlimit) = range(22)
.
.
.
class UncertaintyTableModel(QAbstractTableModel):
def __init__(self, parent=None):
super(UncertaintyTableModel, self).__init__(parent)
self.uncertainties = []
.
.
.
def data(self, index, role=Qt.DisplayRole):
if not index.isValid() or \
not (0 <= index.row() < len(self.uncertainties)):
return QVariant()
uncertainty = self.uncertainties[index.row()]
column = index.column()
if role==Qt.DisplayRole:
if column == name:
return QVariant(uncertainty.name)
elif column == description:
return QVariant(uncertainty.description)
.
.
.
return QVariant()
_______________________________________________
PyQt mailing list [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt