Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Get pixel position under mouseclick in QGraphicsPixmapItem

Get pixel position under mouseclick in QGraphicsPixmapItem

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 725 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zed961
    wrote on last edited by zed961
    #1

    What I want to achieve
    I want to create a QGraphicsViewer that can zoom in,out and get the position of a pixel under mouseclick from an image.

    What I did so far
    I've successfully created my QGraphicsViewer that can zoom in on the image.

    Problem
    How to get the pixel position (X,Y) of the image under the mouseclick? A simple mouseclick event is not working as it's not taking into account that the image scales after zooming see image bellow.

    No Zoom: Notice the pixel at 2,2 at the top.
    0_1475741279787_Image 1.png

    After Zooming: pixel at 2,2 is different from the first image.
    0_1475741398703_Image 2.png

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      zed961
      wrote on last edited by
      #2

      Solved it!

      Create a customScene, override mousepressevent and use scenePos().

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved