#include <QtGui>
Q_OBJECT
Q_PROPERTY(int rot1 READ rot1 WRITE setRot1);
Q_PROPERTY(int rot2 READ rot2 WRITE setRot2);
public:
Widget
(QWidget *parent
= 0) : QWidget(parent
) { m_rot1
= 0; m_rot2
= 0;
} void setPixmap1
(QPixmap px
) { m_px1
= px; update
();
} void setPixmap2
(QPixmap px
) { m_px2
= px; update
();
} int rot1() const { return m_rot1; }
int rot2() const { return m_rot2; }
public slots:
void setRot1(int r1) { m_rot1 = r1; update(); }
void setRot2(int r2) { m_rot2 = r2; update(); }
protected:
p.
setRenderHint(QPainter::Antialiasing);
p.translate(width()/2, height()/2);
if(!m_px1.isNull()) {
p.save();
p.rotate(m_rot1);
p.drawPixmap(r, m_px1);
p.restore();
}
if(!m_px2.isNull()) {
p.save();
p.rotate(m_rot2);
p.drawPixmap(r, m_px2);
p.restore();
}
}
private:
int m_rot1;
int m_rot2;
};
#include "main.moc"
int main(int argc, char **argv) {
Widget w;
w.
setPixmap1(QPixmap("/usr/share/icons/default.kde4/64x64/actions/system-lock-screen.png"));
w.
setPixmap2(QPixmap("/usr/share/icons/default.kde4/64x64/actions/application-exit.png"));
w.resize(100,100);
QPropertyAnimation anim1(&w, "rot1");
QPropertyAnimation anim2(&w, "rot2");
anim1.setStartValue(0);
anim2.setStartValue(0);
anim1.setEndValue(359);
anim2.setEndValue(-359);
anim1.setLoopCount(-1);
anim2.setLoopCount(-1);
anim1.setDuration(5000);
anim2.setDuration(3000);
anim1.start();
anim2.start();
w.show();
return app.exec();
}