[PyQt] Resize columns in QTreeViewv

Hans Meine meine at informatik.uni-hamburg.de
Wed Nov 24 10:36:56 GMT 2010


Hi again!

Op den Dingsdag 23 November 2010 Klock 23:39:11 hett Gionata Boccalini 
schreven:
> Ok , but if I specify the filters in this way:
> 
> self.__fileModel.setFilter(QDir.AllDirs|QDir.Files|QDir.NoDotAndDotDot)
> 
> all the directories are shown, and all the files... I want only the
> files, but if QDir.AllDirs must be specified how can it be possible??
> I am sorry if I am wasting your time, but I can't understand!!

Maybe the docs are misleading.. I tried your attachment and got the same.  
THinking about it, setFilter(QDir.Files) is obviously right, so you'll need to 
use setRootPath:

    @QtCore.pyqtSlot('QModelIndex')
    def updateFiles(self,  index):
        path = self.__dirModel.filePath(index)
        self.__fileModel.setRootPath(path) # <- I added this line
        fileIndex = self.__fileModel.index(path)
        self.__fileView.setRootIndex(fileIndex)
        QTimer.singleShot(400, self.resizeColumn)

HTH,
  Hans


More information about the PyQt mailing list