Derek
Derek

Reputation: 11915

send mouse position data from QGraphicsItem to label on mainwindow

I created a custom QGraphicsItem and I am able to find the mouse position over the image by overriding the hoverMoveEvent.

How can I send that position data to a QLabel that is in my main window, that has my GraphicsView so that the label is always showing the pixel coordinates over the main label? Do I have to use a timer or something?

Upvotes: 0

Views: 431

Answers (1)

thorsten müller
thorsten müller

Reputation: 5651

I would use the signal/slot mechanism of Qt to do this.

Declare a custom signal in your QGraphicsItem.

Connect your signal with the setNum or setText slot of the QLabel.

emit the signal after you read the mouse position.

Upvotes: 3

Related Questions