Results 1 to 4 of 4

Thread: Image Zoom in/out

  1. #1
    Join Date
    Sep 2013
    Posts
    107
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Image Zoom in/out

    Dear All,

    I need to zoom the image, which is set in the QLabel with QPixmap. Here my label size is fixed (350,450). In this i have loaded pixmap image.png which is of size 900*732. I have scaled the content while in the Ui form. Now I need to Zoom-in/out the image inside the QLabel. Plz sugest me.

  2. #2
    Join Date
    Sep 2013
    Posts
    107
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Image Zoom in/out

    Hi to all...wat may be solution for this whether keeping scaled content in ui form is wrong or wat... Basically I need to know how zoom process is done on image which is loaded on q label

  3. #3
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Image Zoom in/out

    Quote Originally Posted by Vivek1982 View Post
    Hi to all...wat may be solution for this whether keeping scaled content in ui form is wrong or wat... Basically I need to know how zoom process is done on image which is loaded on q label
    use QPixamp::scaled to fit the pixmap to the relevant widget. Find what happens if you give sizes outside the range of the widget. It may also be good that you take a look at Qt Image Viewer example.

  4. #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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.