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. Zoom problem in QGraphicsView
Forum Updated to NodeBB v4.3 + New Features

Zoom problem in QGraphicsView

Scheduled Pinned Locked Moved Solved General and Desktop
1 Posts 1 Posters 400 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.
  • ivanicyI Offline
    ivanicyI Offline
    ivanicy
    wrote on last edited by ivanicy
    #1

    Hello!

    I am trying to develope the zoom function in a QGraphicsView.

    I have this code:

    double scaleFactor = 1.15;
    double currentScale = 1.0;
    double scaleMin = 1.00;
    
    void imageView::wheelEvent(QWheelEvent *event) {
        /* MODO POR DEFECTO (ZOOM) ****************************************************************************** */
        if (graphicMode == ZOOM_MODE) {
        //if (sceneMode == NoMode) {
            this->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
            if (event->delta() > 0) {
                this->scale(scaleFactor, scaleFactor);
                currentScale *= scaleFactor;
            } else if (currentScale > scaleMin && (currentScale / scaleFactor) >= scaleMin ) {
                this->scale(1/scaleFactor, 1/scaleFactor);
                currentScale /= scaleFactor;
            } else if (currentScale <= scaleMin) {
                //currentScale = scaleMin;
            }
            this->centerOn(event->pos());
    
            _pan = false;
        }
        /* ****************************************************************************************************** */
    }
    

    I have a problem with this sequence:

    1. I do zoom in in the image.
    2. I move the mouse cursor position.
    3. When I do zoom out, the zoom doesn't do it correctly. The position of the zoom out isn't correct.

    What could be the mistake?

    Thank you very much!!

    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