Qt Picture rotation

Source: Internet
Author: User

There are two methods currently found, as follows:

1, the use of qpixmap transformed function rotation, the function by default is the image Center for the rotation point, not arbitrarily set the rotation point, using the following:

Qmatrix Leftmatrix;
Leftmatrix.rotate (180);

Qlabel *plabel= new Qlabel ();
Plabel->setpixmap (Qpixmap (":/images/img.png"). Transformed (leftmatrix,qt::smoothtransformation));

The result is a 180 degree rotation of the clockwise meter.

2. Using Qpainter class

void Dialog::p aintevent (qpaintevent *)
{
qpainter painter (this);
QPIXMAP pix;
Pix.load ("Images/img.png");
Painter.translate (50,50); Make the center of the picture the center of the rotation
Painter.rotate (90); Rotate clockwise 90 degrees
Painter.translate ( -50,-50); Restore the origin.
Painter.drawpixmap (0,0,100,100,pix);
}

http://blog.csdn.net/itjobtxq/article/details/9231103

Qt Picture rotation

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.