[PyQt] QDirModel instance

Scott Frankel frankel at circlesfx.com
Thu Jul 10 06:39:27 BST 2008


Hello,

I just joined this list and am new to PyQt (and Qt).  I've scanned the  
archives, but I'm not sure even what I'm looking for to answer my  
question.

I'm looking over some C++ code, trying to rewrite it in Python.  (My  
Spanish is much better than my C++!)  I'm sub-classing and extending  
QDirModel and getting the following error:

	TypeError: first argument of unbound method QDirModel.data() must be  
a QDirModel instance

The C++ methods are:

     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);
         }
         return QDirModel::data(index, role);
     }


My translation so far looks like this:


[ ... ]
class DirModel(QtGui.QDirModel):
	def data(self, index, role=QtCore.Qt.DisplayRole):
		if (role == QtCore.Qt.CheckStateRole and index.column() == 0):
			return checkstates.value(fileInfo(index).absoluteFilePath(),  
QtCore.Qt.Unchecked)
		return QtGui.QDirModel.data(index, role)
[ ... ]


Not sure how to make the first argument (index or self?) be a  
QDirModel instance.  Ultimately I'm hoping for a directory tree with  
check boxes.

Suggestions?

Thanks in advance!
Scott






-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20080710/99886a7a/attachment.html


More information about the PyQt mailing list