[PyQt] Resize columns in QTreeViewv

Gionata Boccalini gion at ngi.it
Wed Nov 24 20:53:57 GMT 2010


Ok, now I have this slot:

  def updateFiles(self,  index):
         path = self.__dirModel.filePath(index)
         self.__fileModel.setRootPath(path)
         self.__fileModel.setFilter(QDir.Files)
         fileIndex = self.__fileModel.index(path)
         self.__fileView.setRootIndex(fileIndex)
         QTimer.singleShot(400, self.resizeColumn)


but there is ANOTHER problem!! Again!
Let this be a dirs tree:

     A
      |__ B
      |__ C
      |__ ...

If I select A I can see only files and this is right.  Then if I select 
B I can see only files again and this is right!! But then if I select A 
folder again I can see files and the B folder!!!!!!!! And that is NOT 
right. Note that I am applying the Files filter in the slot too, so 
every time the setRootPath method is called!
Nothing has changed in the constructor except for this tow lines:

     self.__fileModel.setRootPath(QDir.homePath())
     self.__fileModel.setFilter(QDir.Files)

Thanks in advance for your help!!!

Gionata Boccalini


Il 24/11/2010 11:38, Hans Meine ha scritto:
> Op den Dingsdag 23 November 2010 Klock 18:03:15 hett Hans Meine schreven:
>> void QFileSystemModel::setFilter ( QDir::Filters filters )
>> Sets the directory model's filter to that specified by filters.
>> *Note that the filter you set should always include the QDir::AllDirs* enum
>> value, otherwise QFileSystemModel won't be able to read the directory
>> structure.
> Turns out that in this case, this warning does not apply, since Gionata does
> not need the fileModel to read the directory structure (there's a separate
> pane for that).  I find the "should always include" misleading in that
> context.
>
> Ciao,
>    Hans
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt


More information about the PyQt mailing list