ich brauchte ein rotierendes Rad - was mit folgenden Code Stücken möglich war:
Code: Alles auswählen
wheelWidget::wheelWidget(QWidget *parent) : QGraphicsView(parent)
{
this->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
// setViewport(new QGLWidget);
setViewport(new QOpenGLWidget);
this->setViewportUpdateMode(QGraphicsView::NoViewportUpdate);
wheel_pix = QPixmap(":/wheel.png");
this->setOptimizationFlags(QGraphicsView::DontSavePainterState | QGraphicsView::DontAdjustForAntialiasing);
this->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
this->setAttribute(Qt::WA_NoSystemBackground);
QGraphicsScene *scene = new QGraphicsScene(this);
scene->setItemIndexMethod(QGraphicsScene::NoIndex);
setScene(scene);
QLabel *rotateWheel = new QLabel();
rotateWheel->setPixmap(wheel_pix);
rotateWheel->setStyleSheet("background: transparent");
QGraphicsProxyWidget *rotateWheelItem = scene->addWidget(rotateWheel);
rotateWheelItem->setTransformOriginPoint((qreal)rotateWheel->width()/(qreal)2, (qreal)rotateWheel->height()/(qreal)2);
rotateWheel_animation = new QPropertyAnimation(rotateWheelItem, "rotation", this);
rotateWheel_animation->setDuration(14400);
rotateWheel_animation->setEasingCurve(QEasingCurve::InOutCubic);
connect(this, SIGNAL(start_now_wheel()), rotateWheel_animation, SLOT(start()));
connect(rotateWheel_animation, SIGNAL(finished()), this, SLOT(animation_wheel_finish()));
..
Gruß Thomas