Results 1 to 4 of 4

Thread: Image Zoom in/out

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Image Zoom in/out

    Label is just a simple display widget, it doesn't have any image processing capabilities or view abstraction, so you have to do all the math yourself (there is nothing like QLabel::setZoom or QPixmap::setZoom). You can save the original image, select the area of the image via QPixmap::copy method and set it as the new label's pixmap. On each zoom change.
    Alternative is to use QGraphicsView, add the image to scene, and then use transformation matrix to manipulate the scaling effect (m11() and m22() for horizontal / vertical scaling factors respectively), or "QGraphicsView::scale" method. More efficient and easier to implement.

    Another option if you want to stick to QLabel is to subclass it, reimplement paintEvent and implement zoom by proper combinations of QPainter transformations (translate / scale).
    Last edited by stampede; 22nd November 2013 at 20:12.

Similar Threads

  1. How to zoom image correctely in QML?
    By chong_kimkeang in forum Newbie
    Replies: 1
    Last Post: 21st November 2012, 10:42
  2. Replies: 1
    Last Post: 9th October 2012, 12:32
  3. Replies: 1
    Last Post: 17th October 2011, 13:56
  4. QWTPlot Zoom: cannot zoom negative value
    By jwieland in forum Qwt
    Replies: 0
    Last Post: 8th January 2010, 16:16
  5. missing image with zoom (QGraphicsView)
    By avis_phoenix in forum Qt Programming
    Replies: 7
    Last Post: 18th March 2009, 13:09

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.