I'm using Qt Designer to make a simple widget with a QGraphicsView in it. My problem is when I write the main program and try to use the QGraphicsView from the gui file, I can't get any events.
Here's an example of what I'm trying to do. This code is generated from Qt Designer:
Qt Code:
  1. from PyQt4 import QtCore, QtGui
  2.  
  3. try:
  4. _fromUtf8 = QtCore.QString.fromUtf8
  5. except AttributeError:
  6. _fromUtf8 = lambda s: s
  7.  
  8. class Ui_graphicsViewWidget(object):
  9. def setupUi(self, graphicsViewWidget):
  10. graphicsViewWidget.setObjectName(_fromUtf8("graphicsViewWidget"))
  11. graphicsViewWidget.resize(400, 300)
  12. graphicsViewWidget.setMouseTracking(True)
  13. self.graphicsView = QtGui.QGraphicsView(graphicsViewWidget)
  14. self.graphicsView.setGeometry(QtCore.QRect(70, 40, 256, 192))
  15. self.graphicsView.setObjectName(_fromUtf8("graphicsView"))
  16.  
  17. self.retranslateUi(graphicsViewWidget)
  18. QtCore.QMetaObject.connectSlotsByName(graphicsViewWidget)
  19.  
  20. def retranslateUi(self, graphicsViewWidget):
  21. graphicsViewWidget.setWindowTitle(QtGui.QApplication.translate("graphicsViewWidget", "Form", None, QtGui.QApplication.UnicodeUTF8))
To copy to clipboard, switch view to plain text mode 

This is my part of the code:

Qt Code:
  1. #!/usr/bin/python -d
  2.  
  3. import sys
  4. from PyQt4.QtCore import *
  5. from PyQt4.QtGui import *
  6. from gui import Ui_graphicsViewWidget
  7.  
  8. class MyForm(QMainWindow):
  9.  
  10. def __init__(self, parent=None):
  11. QWidget.__init__(self, parent)
  12. self.ui = Ui_graphicsViewWidget()
  13. self.ui.setupUi(self)
  14. self.ui.graphicsView.setFocus(True)
  15.  
  16. def mousePressEvent(self, event):
  17. print("mouse pressed")
  18.  
  19.  
  20. if __name__ == "__main__":
  21. app = QApplication(sys.argv)
  22. myapp = MyForm()
  23. myapp.show()
  24. sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode 

Basically what I want here is when I click on the QGraphicsView, I want to capture the mousePressEvent and print something.
I've tried everything I can think of and searched all over the wed, still can't find a solution.

I can accomplish this by writing the whole gui out by hand but I want to know how to do this with Qt Designer.

Thanks for your help.