代码如下:
#pragma once
#include <QLabel>
class comRotateLabel : public QLabel
{
Q_OBJECT
public:
comRotateLabel(QWidget *parent);
~comRotateLabel();
void SetImage(QImage * image);
void SetImage(QString &imagePath);
void SetRotate(int rotate);
protected:
void paintEvent(QPaintEvent *e);
private:
QImage m_image;
int m_rotate;
};
#include <QPainter>
#include "comRotateLabel.h"
comRotateLabel::comRotateLabel(QWidget *parent)
: QLabel(parent)
, m_rotate(0)
{
}
comRotateLabel::~comRotateLabel()
{
}
void comRotateLabel::SetImage(QImage * image)
{
m_image = *image;
}
void comRotateLabel::SetImage(QString &imagePath)
{
m_image.load(imagePath);
}
void comRotateLabel::SetRotate(int rotate)
{
m_rotate = rotate;
}
void comRotateLabel::paintEvent(QPaintEvent *e)
{
QPainter painter(this);
painter.setPen(Qt::NoPen);
painter.setBrush(Qt::NoBrush);
painter.setRenderH