QTransform transform; transform.translate(20,20); transform.rotate(60,Qt::YAxis); pixmapItem->setTransform(transform);
#include "widget.h"#include <QApplication>#include <QGraphicsScene>#include <QGraphicsPixmapItem>#include <QGraphicsDropShadowEffect>#include <QGraphicsView>int main(int argc, char *argv[]){ QApplication app(argc,argv); QGraphicsScene scene; QGraphicsPixmapItem* pixmapItem = new QGraphicsPixmapItem(*(new QPixmap(":/Number.jpg"))); pixmapItem->setFlags(QGraphicsItem::ItemIsMovable); QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect(); effect->setBlurRadius(20); effect->setOffset(20,20); pixmapItem->setGraphicsEffect(effect); qreal x = pixmapItem->boundingRect().width()/2; qreal y =pixmapItem->boundingRect().height()/2; QTransform transform; transform.translate(x,y).rotate(60,Qt::XAxis).translate(-x,y); pixmapItem->setTransform(transform); QGraphicsView view(&scene); scene.addItem(pixmapItem); view.showFullScreen(); return app.exec();}