Results 1 to 2 of 2

Thread: problem in scaling images

  1. #1
    Join Date
    Sep 2012
    Qt products

    Exclamation problem in scaling images

    Hi every one. I'm very very beginner in QT. Plz help me if u have any idea for my problem, with many thanks.
    Now my problem:
    In part of my project I load an image and now I want to zoom in/out it; but I can't. The image and "scaleSlider" are shown on the screen properly, but changing scale by scaleSlider does not affect the image. this is my code:
    Qt Code:
    1. void PanelWidgets::slotChangeImage(int val)
    2. {
    3. image.scaled(image.width()*val/100, image.height()*val/100);
    4. qDebug()<<val;
    5. }
    To copy to clipboard, switch view to plain text mode 
    and after many lines, we have:
    Qt Code:
    1. bool b = image.load(":res/dab/logo.jpg");
    2. if(!b) qDebug()<<"Can not load image from path";
    3. if(b) scene->addPixmap(QPixmap::fromImage(image));
    4. QSlider *scaleslider = new QSlider(Qt::Horizontal,this);
    5. scaleslider->setRange(10,1000);
    6. scaleslider->setGeometry(700,100,200,30);
    7. connect(scaleslider,SIGNAL(valueChanged(int)),this,SLOT(slotChangeImage(int)),Qt::UniqueConnection);
    To copy to clipboard, switch view to plain text mode 
    I'm using QT Creator 2.4.1 (based on QT 4.7.4 32bit) and Win 7 x86.

  2. #2
    Join Date
    Aug 2009
    Thanked 14 Times in 14 Posts
    Qt products
    Unix/X11 Windows

    Default Re: problem in scaling images

    The QImage::scaled() returns a copy of the image scaled to new size
    There is also the Image Viewer Example in docs with zoom-in / zoom-out already implemented for studying

  3. The following user says thank you to Rhayader for this useful post:

    sara2662 (11th September 2012)

Similar Threads

  1. scaling problem in qpixmap
    By erfan in forum Qt Programming
    Replies: 2
    Last Post: 21st June 2012, 08:52
  2. Qwt Log Scaling Problem
    By BettaUseYoNikes in forum Qwt
    Replies: 1
    Last Post: 24th November 2011, 08:20
  3. Translation problem while scaling an object
    By qlands in forum Qt Programming
    Replies: 0
    Last Post: 4th October 2010, 13:04
  4. Pixmap scaling problem
    By tommy in forum Qt Programming
    Replies: 1
    Last Post: 14th May 2009, 18:00
  5. Scaling Painter without scaling the coordinate sytem
    By maverick_pol in forum Qt Programming
    Replies: 4
    Last Post: 7th January 2008, 22:30

Tags for this Thread


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.