Fabulous!


On Jul 10, 2008, at 2:08 PM, Andreas Pakulat wrote:

On 10.07.08 11:46:36, Scott Frankel wrote:

Right.  Thanks for pointing out that I still need to explicitly pass
"self."

I'm still not getting checkboxes displayed in the tree widget, though. I believe the problem is in the nested return value in the model's data()
method.

The C++ example code I'm following uses a QMap data structure to hold
checkState values. After reading Assistant notes, a python dir(QtCore), and some googling, I've found that QMap is not implemented in PyQt. So
I'm using a Dict instead.  Still, my app complains:

        TypeError: invalid result type from DirModel.data()


Here's the C++ code I'm following:

   virtual QVariant data(const QModelIndex &index, int role =
Qt::DisplayRole) const
   {
       if (role == Qt::CheckStateRole && index.column() == 0) {
return checkstates.value(fileInfo(index).absoluteFilePath(),
Qt::Unchecked);

You need to wrap that in a QVariant, i.e.

return QVariant(....)

data() needs to return a QVariant and Python doesn't support the
implicit constructors as C++ does.

Andreas

--
You will pass away very quickly.
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Scott Frankel
President/VFX Supervisor
Circle-S Studios
510-339-7477 (o)
510-332-2990 (c)




_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to