..._qt qpropertyanimation颜色渐变">
当前位置:   article > 正文

QPainter QConicalGradient QPropertyAnimation 绘制雷达_qt qpropertyanimation颜色渐变

qt qpropertyanimation颜色渐变

一、效果预览图
在这里插入图片描述
二、代码构造思路
QPainter绘制背景图、QConicalGradient 构造颜色渐变对象、利用QPropertyAnimation创建动画
三、代码片段

#include "radarcycle.h"

RadarCycle::RadarCycle(QWidget *parent):
    QWidget (parent)
{
   
    resize(parent->size());
    show();
    init();
}
int RadarCycle::getRotate()
{
   
    return m_rotation;
}

void RadarCycle::setRotate(int rotate)
{
   
    m_rotation = rotate;
    update();
}
void RadarCycle::init()
{
   
    m_rotation = 0;
    QPropertyAnimation *animation = new QPropertyAnimation(this, "rotate");
    animation->setEasingCurve(QEasingCurve::Linear);
    animation->setDuration(18000);
    animation->setStartValue(0);
    animation->setEndValue(360);
    animation->setLoopCount(-1);
    animation->start(QAbstractAnimation::DeleteWhenStopped);
}

void RadarCycle::paintEvent(QPaintEvent *event)
{
   
    paintCycle(event,46,1);
    paintCycle(event,46*2,1);
    paintCycle(event,46*3,1);
    paintCycle(event,46*4,1);
    paintCycle(event,46*5,4);
    paintTextScale(event);
    paintLine(event);
    paintPie(event);
}

void RadarCycle::paintCycle(QPaintEvent *event,int r,int w)
{
   
    QRect rect = event->rect();
    if
  • 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
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/282856
推荐阅读
相关标签
  

闽ICP备14008679号