I would like to know the path of the selected item in a QTreeView, I can save the path in a variable.
Code:
import subprocessfrom PyQt4 import QtCore, QtGuiimport osimport sysfrom LoVE import Ui_Formclass navegador(QtGui.QWidget): def __init__(self): QtGui.QWidget.__init__(self) self.ventana = Ui_Form() self.ventana.setupUi(self) self.setWindowIcon(QtGui.QIcon('zoe.png')) self.model = QtGui.QDirModel() self.ventana.T1.setModel(self.model) self.connect(self.ventana.B1, QtCore.SIGNAL('clicked()'), self.mostrar_dialogo) self.connect(self.ventana.B2, QtCore.SIGNAL('clicked()'), self.comprimir) # "T1" is the QTreeView. I don't know how to determine the path. liz = self.connect(self.ventana.T1.selectionModel(), QtCore.SIGNAL("clicked()"), self.sa) def sa(selected, deselected): print liz # Please Help Me def mostrar_dialogo(self): global filename filename = QtGui.QFileDialog.getOpenFileName(self, 'Abrir archivo', '/home') def comprimir(self): print filename subprocess.call(["zip", filename + ".zip", filename])def main(): app = QtGui.QApplication(sys.argv) ventana = navegador() ventana.show() sys.exit(app.exec_())if __name__ == '__main__': main()
Please help me