PDA

View Full Version : loading image from disk



freekill
18th February 2010, 04:27
I'm trying to load an image file from disk and I would like to draw the same image along with a rectangle whose size is updated using spin boxes. However, I couldn't load the image. I'm using this code:



QImage img("/c/documents and settings/usr/desktop/c++/qt/experiments/boundary/sample.jpg",0)
QPixmap pixmap = QPixmap::fromImage(image);


The image file is named as sample.jpg. Thanks for the help.

BalaQT
18th February 2010, 05:21
hi

QImage img("/c/documents and settings/usr/desktop/c++/qt/experiments/boundary/sample.jpg",0);
the path specified is wrong.
try

QImage img("c:\documents and settings\usr\desktop\c++\qt\experiments\boundary\s ample.jpg",0);

or try

QImage img("c:\\documents and settings\\usr\\desktop\\c++\\qt\experiments\\bound ary\\sample.jpg",0);

however u can directly load image in QPixmap

QPixmap *img=new QPixmap("c:\documents and settings\usr\desktop\c++\qt\experiments\boundary\s ample.jpg");


hope it helps
Bala