包含头文件
#include <QImage>#include <QPixmap>#include <QMatrix>
原图
QImage image;image.load("D:/1651966162841_Onue_.jpg");ui->label->setPixmap(QPixmap::fromImage(image).scaled(ui->label->size()));
水平翻转
QImage image2;image2 = image.mirrored(true,false);ui->label->setPixmap(QPixmap::fromImage(image2).scaled(ui->label->size()));
垂直翻转
QImage image3;image3 = image.mirrored(false,true);ui->label->setPixmap(QPixmap::fromImage(image3).scaled(ui->label->size()));
顺时针/逆时针旋转
QImage image4;QMatrix matrix;matrix.rotate(30.0);//旋转角度,正数是顺时针负数是逆时针image4 = image.transformed(matrix,Qt::FastTransformation);ui->label->setPixmap(QPixmap::fromImage(image4).scaled(ui->label->size()));