标签:
self.TreeImage.clicked.connect(self.on_treeview_click)
#treeview右击
@pyqtSlot("QItemSelection, QItemSelection")
@pyqtSlot(QModelIndex)
#显示效果#右击部分先暂时这样
def on_treeview_click(self,index):
index1=self.TreeImage.model().index(index.row(), 0, index.parent())
fileName=self.TreeImage.model().fileName(index1)
filePath=self.TreeImage.model().filePath(index1)
return (unicode(fileName),unicode(filePath))
def on_treeView_customContextMenuRequested(self):
self.setContextMenuPolicy(Qt.CustomContextMenu)
self.menu1=QMenu(self.TreeImage)
index=self.TreeImage.currentIndex()
filename=self.TreeImage.model().data(self.TreeImage.model().index(index.row(),0),0).toString()
menu1=self.menu1.addAction(u‘打开‘)
action1=QAction(u‘删除‘,self)
self.menu1.addAction(action1)
menu2=self.menu1.addMenu(u‘其他‘)
menu2.addAction(u‘属性‘)
def models(self):
self.dirmode=QDirModel(self)
#self.dirmode.setFilter(QDir.Dirs|QDir.NoDotAndDotDot)#只显示列表,不显示文件
#fileter=[‘*.jpg‘,‘*.gif‘,‘*.bmp‘,‘*.png‘]
#self.dirmode.setNameFilters(fileter)
self.TreeImage.setModel(self.dirmode)
self.TreeImage.hideColumn(1)
self.TreeImage.hideColumn(2)
self.TreeImage.hideColumn(3)
标签:
原文地址:http://www.cnblogs.com/mhxy13867806343/p/4299991.html