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:
Code:
void PanelWidgets::slotChangeImage(int val)
{
image.scaled(image.width()*val/100, image.height()*val/100);
qDebug()<<val;
}
and after many lines, we have:
Code:
bool b = image.load(":res/dab/logo.jpg");
if(!b) qDebug()<<"Can not load image from path";
if(b
) scene
->addPixmap
(QPixmap::fromImage(image
));
scaleslider->setRange(10,1000);
scaleslider->setGeometry(700,100,200,30);
connect(scaleslider,SIGNAL(valueChanged(int)),this,SLOT(slotChangeImage(int)),Qt::UniqueConnection);
I'm using QT Creator 2.4.1 (based on QT 4.7.4 32bit) and Win 7 x86.
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 http://doc.qt.nokia.com/4.7-snapshot...ageviewer.html with zoom-in / zoom-out already implemented for studying