I have a QGraphicsView created in the QtDesigner. Now I want to connect a mouseMoveEvent to it. I understand that I must define a new class that inherits from QGraphicsView and in which mouseMoveEvent is overwritten. Here is a pretty good explanation how to do this.
So I have promoted my QGraphicsView instance in QtDesigner to the new class floorplanView. I would like to define this class in my main python file main.py as it is done in the other example:
import QtGui
class floorplanViewClass(QtGui.QGraphicsView):
moved = pyqtSignal(QMouseEvent)
def __init__(self, parent = None):
super(MyView, self).__init__(parent)
def mouseMoveEvent(self, event):
super(MyView, self).mouseMoveEvent(event)
print "Mouse Pointer is currently hovering at: ", event.pos()
self.moved.emit(event)
My first question: What do I have to enter in the Header file field? Both main.h and just main give me:
File "<stdin>", line 1, in <module>
File "C:\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 699, in runfile
execfile(filename, namespace)
File "C:\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 74, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)
File "C:/Users/Oliver/Desktop/pyqt/DRS.py", line 23, in <module>
Ui_MainWindow, QtBaseClass = uic.loadUiType(qtCreatorFile)
File "C:\Anaconda2\lib\site-packages\PyQt4\uic\__init__.py", line 211, in loadUiType
exec(code_string.getvalue(), ui_globals)
File "<string>", line 1317, in <module>
File "DRS.py", line 23, in <module>
Ui_MainWindow, QtBaseClass = uic.loadUiType(qtCreatorFile)
File "C:\Anaconda2\lib\site-packages\PyQt4\uic\__init__.py", line 211, in loadUiType
exec(code_string.getvalue(), ui_globals)
File "<string>", line 1317, in <module>
ImportError: cannot import name floorplanViewClass
PyQt is version 4.