Create the images directory in the debug directory and put the picture linux.jpg
qpainter painter (this);
QPIXMAP pix;
Pix.load ("images/linux.jpg");
Painter.drawpixmap (0,0,100,100,pix); Painter.translate (100,100); Set (100,100) as the origin of the coordinates.
Painter.drawpixmap (0,0,100,100,pix);
Why Pix.load ("images/linux.jpg"); Can't load pictures?
But this writes pix.load ("E:\\linux.jpg"); Specify an absolute path to find the file
Use the absolute path, using the "/" instead of "\" such as Pix.load ("c:/qt/test/15/painter05-build-desktop_qt_5_0_1_mingw_32bit-debug/debug/ Images/1.jpg ");
BOOL flag = Px.load ("Icon6.png"); BOOL Flag1 = px.load ("Resource\\icon6.png"); In fact, the relative path used is not correct. It is not always important to use absolute paths.
BOOL Flag2 = px.load ("Resource/icon6.png"); "Debug/resource/zbc1.jpg"------true
BOOL Flag3 = px.load ("E:/thybot/svn/trunk/istore/build-debug/debug/resource/icon6.png");
Plabel->setpixmap (px);
Plabel->setframestyle (qframe::P anel | Qframe::sunken); Set appearance
Plabel->setscaledcontents (TRUE);
Operation Result:
Link:qpixmap Load function problem