qt html图片旋转,QT 图片旋转--QTransform 沿中间旋转

#ifndef shadow_H_

#define shadow_H_

#include

#include

class ShadowWidget : public QWidget

{

Q_OBJECT

public:

ShadowWidget(QWidget *parent =0)

{

//setWindowFlags(Qt::FramelessWindowHint);

QGraphicsDropShadowEffect *fEffect =  new QGraphicsDropShadowEffect;

//fEffect->setColor(QColor(255,0,0));

QVBoxLayout *layout = new QVBoxLayout(this);

QGraphicsScene *scene = new QGraphicsScene;

scene->setSceneRect(QRect(0,0,900,600));

fPixmap= new QGraphicsPixmapItem;

fPixmap->setPos(200,200);

QPixmap *pix = new QPixmap("1.jpg");

fPixmap->setPixmap(*pix);

//fPixmap->setGraphicsEffect(fEffect);

QTransform *tran = new QTransform;

tran->rotate(80,Qt::YAxis);

//fPixmap->setTransform(*tran);

//fPixmap->setTransformOriginPoint(QPointF(pix->size().width()/2,pix->size().height()/2));

//fPixmap->setTransformOriginPoint(100,100);

scene->addItem(fPixmap);

QGraphicsView *view = new QGraphicsView(scene);

layout->addWidget(view);

QPushButton * animButton = new QPushButton(tr("Start"));

layout->addWidget(animButton);

connect(animButton,SIGNAL(clicked()),this,SLOT(performAnimation()));

//setGraphicsEffect(fEffect);

resize(900,600);

fTimeLine = NULL;

}

private slots:

void performAnimation()

{

if(!fTimeLine)

{

fTimeLine = new QTimeLine;

fTimeLine->setDuration(1000);

fTimeLine->setFrameRange(1,10);

connect(fTimeLine,SIGNAL(frameChanged(int)),this,SLOT(performRotateAnimation(int )));

}

fTimeLine->start();

}

void performRotateAnimation(int frame)

{

qreal angle = 90*(frame)/10.0;

QTransform tran;

tran.translate(150,0);

//fPixmap->setTransformOriginPoint(0,0);

tran.rotate(angle,Qt::YAxis);

fPixmap->setTransform(tran);

QTransform t;

t.translate(-150,0);

fPixmap->setTransform(t,true);

}

private:

QGraphicsPixmapItem *fPixmap;

QTimeLine *fTimeLine ;

};

#endif

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值