mouseePress / mouseEvent , cursor coordinates & zoom issue
Hi ,
i'm a beginner in PyQt and i want to know please : what's the difference between mousePressEvent() and mouseReleaseEvent() ? :rolleyes:
also i've another issue : i showed an image on a QgraphicsView like this : QImage ( path ) ==> convert to QPixmap ==> set On the QGraphicsView's Scene
is it possible to have the cursor coordinates Inside the image without clicking on any mouse or keybord button ? just navigating Inside the image and showing image pixel coordinates on the status bar ? :confused:
i'd like also to code a zoom function usine wheelEvent or comboBox :
i used the QImage instance and apply scale(current.width * zoom_factor, current.height() * zoom_factor) function , the problem i want the zoom to be centered around the current position of the cursor.
using , my method i have to use scroll bars each time i zoom to see the region i wanted to see ... and that's not cool :(
Thanks for reading ,
Re: mouseePress / mouseEvent , cursor coordinates & zoom issue
Quote:
Originally Posted by
Qtdigitex
i'm a beginner in PyQt and i want to know please : what's the difference between mousePressEvent() and mouseReleaseEvent() ? :rolleyes:
As their names say, one is called when a mouse button is pressed, the other one when a mouse button is released.
Quote:
Originally Posted by
Qtdigitex
is it possible to have the cursor coordinates Inside the image without clicking on any mouse or keybord button ? just navigating Inside the image and showing image pixel coordinates on the status bar ? :confused:
You probably need to enable mouse tracking on the view and then implement mouseMoveEvent()
Quote:
Originally Posted by
Qtdigitex
i'd like also to code a zoom function usine wheelEvent or comboBox :
i used the QImage instance and apply scale(current.width * zoom_factor, current.height() * zoom_factor) function , the problem i want the zoom to be centered around the current position of the cursor.
using , my method i have to use scroll bars each time i zoom to see the region i wanted to see ... and that's not cool :(
Do you want to zoom or do you want to scale the elements?
For zooming you can just call scale() on the view and set the transformation anchor to view center.
Cheers,
_
Re: mouseePress / mouseEvent , cursor coordinates & zoom issue
Quote:
Originally Posted by
anda_skoa
As their names say, one is called when a mouse button is pressed, the other one when a mouse button is released.
You probably need to enable mouse tracking on the view and then implement mouseMoveEvent()
Do you want to zoom or do you want to scale the elements?
For zooming you can just call scale() on the view and set the transformation anchor to view center.
Cheers,
_
thanks for responding
1/ Yeah , sorry . English is not my native language. that's why i don't understand what's the difference concretly between both events :rolleyes: :
press is only one press but release : does it mean press for a long time ?
2/ ok, i'll try this
3/ i want to zoom , how can i set transformation Anchor to view center please ? ;) is it possible to set it to any point ? if it is , i can set it to the mouse position recupered from the mouseMoveEvent and it will resolve my problem i think
Added after 1 21 minutes:
2/ the mouseMoveEvent worked ,
3/ the combination of scale() / centerOn() is the solution and it works perfectly :cool:
thanks ,
Re: mouseePress / mouseEvent , cursor coordinates & zoom issue
Quote:
Originally Posted by
Qtdigitex
press is only one press but release : does it mean press for a long time ?
No, press means mouse button went down and release means mouse button went up
Quote:
Originally Posted by
Qtdigitex
3/ i want to zoom , how can i set transformation Anchor to view center please ? ;)
In the documentation for QGraphicsView, click on the transformationAnchor property and you'll get the name of the setter function.
Quote:
Originally Posted by
Qtdigitex
is it possible to set it to any point ?
No, the property is an enum type, it has a fixed set of values.
Quote:
Originally Posted by
Qtdigitex
i can set it to the mouse position recupered from the mouseMoveEvent
Yes, mouse position is one of the options.
Cheers,
_
Re: mouseePress / mouseEvent , cursor coordinates & zoom issue
1/ thanks ,
3/ so , unfortunately the transformationAnchor() functon doesn't resolve the problem , the centerOn / scale combination does better work
Thanks anyway