-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRingWait1.cpp
53 lines (43 loc) · 1.19 KB
/
RingWait1.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "RingWait1.h"
RingWait1::RingWait1(QWidget *parent)
: QDialog(parent)
{
offset=0;
//启动定时器
startTimer(50);
//设置控件大小
setFixedSize(150,150);
//去掉标题栏 设置置顶 去掉任务栏图标
setWindowFlags(Qt::FramelessWindowHint|Qt::Tool|Qt::WindowCloseButtonHint|Qt::WindowStaysOnTopHint);
//设置窗口背景透明
setAttribute(Qt::WA_TranslucentBackground, true);
}
RingWait1::~RingWait1()
{}
void RingWait1::timerEvent(QTimerEvent*)
{
++offset;
if(offset>11)
offset=0;
update();
}
void RingWait1::paintEvent(QPaintEvent*)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing,true); // 反锯齿
int width=this->width();
int height=this->height();
//画笔移动到中间
painter.translate(width >> 1, height>> 1);
//计算偏移坐标
int offsetDest=(width-30)/2;
painter.setPen(Qt::NoPen);
//计算小圆坐标
for(int i=0;i<12;++i){
QPoint point(0,0);
painter.setBrush(QColor(73,124,255,255-i*30));
point.setX(offsetDest*qSin((-offset+i)*M_PI/6));
point.setY(offsetDest*qCos((-offset+i)*M_PI/6));
painter.drawEllipse(point.x()-10, point.y()-10, 20, 20);
}
}