Results 1 to 11 of 11

Thread: Zoom effect by mouse Wheel in QGraphicsview

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Zoom effect by mouse Wheel in QGraphicsview

    having the scene rect bigger thatn view rect shuold make the Zoom effect work as expected, is there any thing else you are missing.

    Other Tools: You can use a normal QWidget and implement paintevent, but you will need to handle zoom effect while painting (will not be as stright forward as in case of QGraphicsView).
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  2. #2
    Join Date
    Dec 2012
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Zoom effect by mouse Wheel in QGraphicsview

    i have all done . but the zoom from mouse pointer is not done, zoom is doing to qgraphics view only

  3. #3
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Zoom effect by mouse Wheel in QGraphicsview

    See if this workaround works, add a QGraphicsRectItem, and set the QGraphicsRectItem rect larger than the screen (monitor) size
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  4. #4
    Join Date
    Jun 2014
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Zoom effect by mouse Wheel in QGraphicsview

    you can find the solution in this form

    http://www.qtcentre.org/wiki/index.p...ng_and_Zooming


    I used it in my code like this :


    Qt Code:
    1. //in header file
    2.  
    3. protected:
    4. virtual void wheelEvent(QWheelEvent* event);
    5.  
    6. //in cpp file
    7. void Dialog::wheelEvent(QWheelEvent *event){
    8.  
    9. ui->graphicsView->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
    10. // Scale the view / do the zoom
    11. double scaleFactor = 1.15;
    12. if(event->delta() > 0) {
    13. // Zoom in
    14. ui->graphicsView-> scale(scaleFactor, scaleFactor);
    15.  
    16. } else {
    17. // Zooming out
    18. ui->graphicsView->scale(1.0 / scaleFactor, 1.0 / scaleFactor);
    19. }
    20.  
    21.  
    22. //ui->graphicsView->setTransform(QTransform(h11, h12, h21, h22, 0, 0));
    23. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Can usb mouse wheel work in Qt/E ?
    By earth in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 26th August 2011, 11:00
  2. Replies: 1
    Last Post: 3rd August 2011, 01:14
  3. Scrolling on Mouse Wheel
    By penny in forum Qt Programming
    Replies: 4
    Last Post: 7th April 2011, 07:30
  4. QGraphicsView - zoom out using the right mouse button
    By dbrmik in forum Qt Programming
    Replies: 1
    Last Post: 14th April 2009, 22:17
  5. QwtPlotMagnifier Invert Wheel Zoom
    By jmsbc in forum Qwt
    Replies: 2
    Last Post: 12th March 2009, 23:12

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
  •  
Qt is a trademark of The Qt Company.