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