"QT5 Development and examples" 14. Implement a simple text editor 3

Source: Internet
Author: User

Implementation of the image rotation function of the text editor basic interface implementation: http://blog.csdn.net/cutter_point/article/details/42839071
First, add the slot function on the original basis:

  void ShowRotate90 ();    Rotates 90 degrees  void ShowRotate180 ();   180 degrees  void ShowRotate270 ();   270 degrees

Function Connection:

  Implementation of the image selection action  //rotation 90 °  rotate90action = new Qaction (Qicon (":/rotate90.png"), tr ("Get Rotate90"), this);  Rotate90action->setstatustip (tr ("Get Rotate90 image"));  Connect (rotate90action, SIGNAL (triggered ()), this, SLOT (ShowRotate90 ()));  180°  rotate180action = new Qaction (Qicon (":/rotate180.png"), tr ("Get rotate180"), this);  Rotate180action->setstatustip (tr ("Get rotate180 image"));  Connect (rotate180action, SIGNAL (triggered ()), this, SLOT (ShowRotate180 ()));  270°  rotate270action = new Qaction (Qicon (":/rotate270.png"), tr ("Get rotate270"), this);  Rotate270action->setstatustip (tr ("Get rotate270 image"));  Connect (rotate270action, SIGNAL (triggered ()), this, SLOT (ShowRotate270 ()));

The specific implementation of the slot function:

Rotates 270 degrees void imageprocessor::showrotate270 () {  if (Img.isnull ())    return;  Qmatrix Matrix;  Matrix.rotate (+);    Rotate 90 degrees  img = img.transformed (matrix);    The image is rotated and then re  -assigned Showwidget->imagelabel->setpixmap (Qpixmap::fromimage (IMG));} Rotates 180 degrees void imageprocessor::showrotate180 () {  if (Img.isnull ())    return;  Qmatrix Matrix;  Matrix.rotate (+);    Rotate 90 degrees  img = img.transformed (matrix);    The image is rotated and then re  -assigned Showwidget->imagelabel->setpixmap (Qpixmap::fromimage (IMG));} Rotates 90 degrees void Imageprocessor::showrotate90 () {  if (Img.isnull ())    return;  Qmatrix Matrix;  Matrix.rotate (+);    Rotate 90 degrees  img = img.transformed (matrix);    The image is rotated and then re  -assigned Showwidget->imagelabel->setpixmap (Qpixmap::fromimage (IMG));}

Implementation results:



"QT5 Development and examples" 14. Implement a simple text editor 3

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.