QFileSystemModel::headerData() is hard coded to return translated versions of "Name", "Size", "Type" or "Kind" and there is no implementation of setHeaderData(). You could use a simple subclass of QFileSystemModel. Something like:
Qt Code:
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import sys
  5. from PyQt4 import QtGui, QtCore
  6.  
  7. class FileSystemModel(QtGui.QFileSystemModel):
  8. def __init__(self):
  9. QtGui.QFileSystemModel.__init__(self)
  10.  
  11. def headerData(self, section, orientation, role):
  12. if orientation == QtCore.Qt.Horizontal and role == QtCore.Qt.DisplayRole:
  13. if section == 0:
  14. result = self.tr('Foo')
  15. elif section == 1:
  16. result = self.tr('Bar')
  17. elif section == 2:
  18. result = self.tr('Baz')
  19. elif section == 3:
  20. result = self.tr('Bob')
  21. else:
  22. result = QtCore.QVariant()
  23. else:
  24. result = super(QtGui.QFileSystemModel, self).headerData(section, orientation, role)
  25. return result
  26.  
  27.  
  28. def main():
  29.  
  30. app = QtGui.QApplication(sys.argv)
  31.  
  32. m = FileSystemModel()
  33. m.setRootPath('/')
  34.  
  35. w = QtGui.QTreeView()
  36. w.setModel(m);
  37. w.resize(640, 480)
  38. w.move(300, 300)
  39. w.setWindowTitle('Simple')
  40. w.show()
  41.  
  42. sys.exit(app.exec_())
  43.  
  44.  
  45. if __name__ == '__main__':
  46. main()
To copy to clipboard, switch view to plain text mode