Python: PyQt QTreeview example - selection

前端 未结 4 1655
醉梦人生
醉梦人生 2020-12-29 14:00

I\'m using Python 2.7 and Qt designer and I\'m new to MVC: I have a View completed within Qt to give me a directory tree list, and the controller in place to run things. My

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-29 14:39

    I tried this alternative to get the file name...

    Instead of:

    indexItem = self.treeview.model.index(index.row(), 0, index.parent())
    
    # path or filename selected
    fileName = self.treeview.model.fileName(indexItem)
    

    I tried:

    # path or filename selected
    fileName = index.internalPointer().fileName
    

    Which also seems to work...

提交回复
热议问题