I'm trying to link a mouse press event to displaying the coordinates of the mouse when clicked in a QLabel
. A few problems... when I was passing a generic QWidget.mousePressEvent
, the coordinates would only display the first time clicked. When I tried to make the mouse event specific to a GraphicsScene(self.p1)
, I get the following error:
Traceback (most recent call last):
File "C:\Users\Tory\Desktop\DIDSONGUIDONOTCHANGE.py", line 59, in mousePressEvent
self.p1.mousePressEvent(event)
TypeError: QGraphicsWidget.mousePressEvent(QGraphicsSceneMouseEvent): argument 1 has unexpected type 'QMouseEvent'
This is the code I'm using... I know it's off but I'm new to this and a bit lost at where to begin.
def mousePressEvent(self, event):
self.p1.mousePressEvent(event)
x=event.x()
y=event.y()
if event.button()==Qt.LeftButton:
self.label.setText("x=%0.01f,y=%0.01f" %(x,y))
How do I get the mouse click to display the coordinates of the graphics scene self.p1?