laurlaur wrote:
Just for a better view
Hi,
I'm new in PyQt programing so please have mercy :)
I want to display the directories content and to catch the event
mouseDoubleClickEvent , but it seems that I have some problems chatching
this event. Eventualy if someone have a better ideea how to do this I'm open
to suggestions.
Below is my code.
import sys
from PyQt4.QtCore import *
from PyQt4.QtNetwork import *
from PyQt4 import QtGui
class miniframe():
def __init__(self, parent =None):
self.tree = QtGui.QTreeView()
self.model = QtGui.QDirModel()
self.tree.setModel(self.model)
self.tree.setGeometry(10,750,400,200)
self.tree.show()
def mouseDoubleClickEvent(self, event):
print "event"
if __name__ =="__main__":
app = QtGui.QApplication(sys.argv)
x =miniframe()
x.show()
sys.exit(app.exec_())
Make sure you inherit from the classes correctly. In your case, you
should inherit from the QTreeView class and then overload the method
mouseDoubleClickEvent().
This snippet below works.
Best regards,
Mads
import sys
from PyQt4 import QtGui
class DirView(QtGui.QTreeView):
def __init__(self, parent =None):
QtGui.QTreeView.__init__(self, parent)
self.model = QtGui.QDirModel()
self.setModel(self.model)
self.setGeometry(10,750,400,200)
def mouseDoubleClickEvent(self, event):
print "event"
if __name__ =="__main__":
app = QtGui.QApplication(sys.argv)
view = DirView()
view.show()
sys.exit(app.exec_())
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt