Use Qpixmap::load to load images in QT

Source: Internet
Author: User



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








Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.