Results 1 to 5 of 5

Thread: mouseePress / mouseEvent , cursor coordinates & zoom issue

  1. #1
    Join Date
    Jul 2016
    Posts
    13
    Qt products
    Platforms
    Windows

    Question 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() ?

    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 ?


    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 ,

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: mouseePress / mouseEvent , cursor coordinates & zoom issue

    Quote Originally Posted by Qtdigitex View Post
    i'm a beginner in PyQt and i want to know please : what's the difference between mousePressEvent() and mouseReleaseEvent() ?
    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 View Post
    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 ?
    You probably need to enable mouse tracking on the view and then implement mouseMoveEvent()


    Quote Originally Posted by Qtdigitex View Post
    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,
    _

  3. #3
    Join Date
    Jul 2016
    Posts
    13
    Qt products
    Platforms
    Windows

    Default Re: mouseePress / mouseEvent , cursor coordinates & zoom issue

    Quote Originally Posted by anda_skoa View Post
    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 :

    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

    thanks ,
    Last edited by Qtdigitex; 13th July 2016 at 14:44.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: mouseePress / mouseEvent , cursor coordinates & zoom issue

    Quote Originally Posted by Qtdigitex View Post
    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 View Post
    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 View Post
    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 View Post
    i can set it to the mouse position recupered from the mouseMoveEvent
    Yes, mouse position is one of the options.

    Cheers,
    _

  5. #5
    Join Date
    Jul 2016
    Posts
    13
    Qt products
    Platforms
    Windows

    Default 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

Similar Threads

  1. Qgraphicsview zoom issue
    By tarunrajsingh in forum Qt Programming
    Replies: 6
    Last Post: 23rd April 2013, 12:28
  2. Replies: 1
    Last Post: 10th April 2013, 10:08
  3. focus out event and cursor issue
    By sajis997 in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2012, 03:55
  4. QGraphcisView issue with mouse cursor image
    By dpatel in forum Qt Programming
    Replies: 0
    Last Post: 20th July 2010, 08:28
  5. Replies: 0
    Last Post: 10th January 2010, 14:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.