-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgear.cpp
37 lines (27 loc) · 820 Bytes
/
gear.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "gear.h"
#include <QPainter>
Gear::Gear(QGraphicsItem *parent): QGraphicsItem(parent) ,mCurrentFrame7() {
setFlag(ItemClipsToShape);
mPixmap7 = QPixmap(":images/dgear15.png");
QTimer *timer = new QTimer(this);
connect(timer,SIGNAL(timeout()),this,SLOT(nextFrame()));
timer->start(100);
}
void Gear::nextFrame(){
mCurrentFrame7 += 95;
if (mCurrentFrame7 >= 4465) {
mCurrentFrame7 = 0;
}
}
QRectF Gear::boundingRect() const {
return QRectF(0,0,95,80);
}
void Gear::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
painter->drawPixmap(0,0, mPixmap7, mCurrentFrame7, 0,95, 80);
setTransformOriginPoint(boundingRect().center());
Q_UNUSED(widget);
Q_UNUSED(option);
}
int Gear::type() const {
return Type;
}