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. Image Zoom in And Zoom Out Using Mouse Scroll
Forum Updated to NodeBB v4.3 + New Features

Image Zoom in And Zoom Out Using Mouse Scroll

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 418 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.
  • F Offline
    F Offline
    FahNos
    wrote on last edited by Chris Kawa
    #1

    Currently, I use the class as below and promote it to graphics view to Zoom in and zoom out image, But I want to stop zoom out when the resolution of image equals the original resolution of image and I want to use press and hold scroll mouse to move picture when the resolution of image bigger than original resolution of image instead of use left mouse. this is my code:

    #include "custom_view.h"
    
    Custom_View::Custom_View(QWidget *parent) : QGraphicsView(parent)
    {
    
    }
    
    void Custom_View::wheelEvent(QWheelEvent *_wheelEvent)
    {
      setTransformationAnchor(AnchorUnderMouse);
      setDragMode(ScrollHandDrag);
      
      double scaleFactor = 1.2;
      if (_wheelEvent->delta()>0){
          scale(scaleFactor,scaleFactor);
        }
      else
        {
          scale(1/scaleFactor,1/scaleFactor);
        }
    }
    

    I am a newbie, Please help me. Thank you so 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