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. Selecting a portion of an image to zoom into in a QGraphicsView

Selecting a portion of an image to zoom into in a QGraphicsView

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.8k Views
  • 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.
  • X Offline
    X Offline
    xtraction
    wrote on last edited by
    #1

    Hello,

    I am using the Graphics framework to show images on the screen with a view, scene and items. I implemented a rubberband as well to "draw" rectangles on top of those images for the purpose of selecting a piece of the image to zoom into.

    So what I want is that when I make a selection of a subarea of my image currently fully displayed in my view, (clicking and holding the mouse, dragging and releasing to make the rubberband rectangle), I want to be able to now see only the selected area in my whole view, so basically have it zoom in to the portion I selected and fit in my viewport only the selected portion, and now of course the scroll bars will appear since the image doesn't fit in the view.

    I'm having a rough time "connecting" or mapping my selected rectangle in the image to calculate how much to scale the image and to have the view display the correct area that I chose.
    Can someone please help me out on what steps do I need to do for this task?

    I was first thinking to get the coordinates of the rubberband rectangle through (Inside my mouseDoubleClickEvent):
    @
    m_rubberband->pos().x() //but in fact what x coordinate does that give me? The topleft corner in this case?
    m_rubberband->pos().y()
    @

    Somehow I need to calculate how much of the image I selected to be able to scale it accordingly? Then the problem of how to make the viewport display correctly what I selected is giving me a hard time..
    Any help will be greatly appreciated.

    Thank you!

    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