资源简介

该表盘效果图地址: https://www.cnblogs.com/lifexy/p/9245918.html 介绍:由于之前上传的表盘是QT4版本的,对有些只学过QT5的同学们不好移植,所以从新上传一个QT5版本的,编码格式为utf-8,该表盘包括了表盘光影效果,渐变效果,可调色等等.

资源截图

代码片段和文件信息

#include “Dial.h“

Dial:: Dial(QWidget *parent  QString labelText QString valueText  QString iconFile ):
    QWidget(parent)
    label(labelText)
    Value_Text(valueText)
    iconfile(iconFile)
    icon(iconFile)
    timer_msec(0)
{

     Scale_decimal=1;                   //设置保留小数点
     center_decimal=1;

     isFlat = false;


     if(!Value_Text.contains(“%1“))
     {
         Value_Text = “%1“;
     }

     radius=0;                          //仪表盘最外圈半径

     minvalue=0;
     maxvalue=120;                     //表盘刻度最大值
     value=20;                         //当前值
     endvalue=0;


     modeColor=ModeSingleColor;

     ScaleColor=QColor(185185185);            //表盘刻度颜色
     PointerColor=QColor(24921);              //指针颜色
     SingleSlideColor =QColor(83213251);      //划过的单颜色
     slideScaleColor = QColor(255255255);     //划过的刻度颜色

     ValueColor=QColor(255255255);            //值颜色(包括标签)
     LabelColor=QColor(192192192);


     obkColor=QColor(252252248);               //外圆背景色

     bkColor=QColor(262626);                   //第二个圆背景色

     centercolor=QColor(383838);                //中心圆盘背景色


     connect(&timerSIGNAL(timeout())thisSLOT(ontimeout()));

}
void Dial::drawObkColor(QPainter& paint)      //绘制外圆
{
        paint.save();

        QConicalGradient  Conical(0090);


        Conical.setColorAt(0obkColor);
        Conical.setColorAt(0.5obkColor);

        Conical.setColorAt(0.12obkColor.darker(80));
        Conical.setColorAt(0.88obkColor.darker(80));

        Conical.setColorAt(0.4obkColor.darker(50));
        Conical.setColorAt(0.6obkColor.darker(50));


        Conical.setColorAt(0.25obkColor.darker(130));

        Conical.setColorAt(0.75obkColor.darker(130));
        Conical.setColorAt(1obkColor);
        paint.setBrush(Conical);
        paint.drawEllipse(QPointF(00) radius*0.96radius*0.98);

        Conical.setAngle(45);

        Conical.setColorAt(0obkColor.darker(130));
        Conical.setColorAt(0.5obkColor.darker(130));

        Conical.setColorAt(0.12obkColor.darker(80));
        Conical.setColorAt(0.88obkColor.darker(80));

        Conical.setColorAt(0.4obkColor.darker(50).darker(130));
        Conical.setColorAt(0.6obkColor.darker(50));


        Conical.setColorAt(0.25obkColor.darker(130));

        Conical.setColorAt(0.75obkColor.darker(130));
        Conical.setColorAt(1obkColor.darker(130));
//        Conical.setColorAt(0obkColor.darker(60));
//        Conical.setColorAt(0.5obkColor.darker(60));

//        Conical.setColorAt(0.25obkColor.darker(130));

//        Conical.setColorAt(0.75obkColor.darker(130));

        paint.setBrush(Conical);
        paint.drawEllipse(QPointF(00) radius*0.93radius*0.94);

        paint.restore();
}
void Dial::drawScalebkColor(QPainter &paint)        //绘制刻度圆
{
    paint.save();

    paint.setBrush(bkColor);
    paint.drawEllip

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      25337  2019-04-20 21:19  Dial_qt5\Dial.cpp

     文件       6712  2019-05-29 14:20  Dial_qt5\Dial.h

     文件       1047  2019-05-29 14:05  Dial_qt5\Dial_qt5.pro

     文件        175  2019-05-29 13:45  Dial_qt5\main.cpp

     文件         99  2019-05-29 14:20  Dial_qt5\res.qrc

     文件       1305  2018-06-29 15:48  Dial_qt5\V.png

     文件       1156  2019-05-29 14:34  Dial_qt5\widget.cpp

     文件        375  2019-05-29 14:20  Dial_qt5\widget.h

     目录          0  2019-05-29 14:36  Dial_qt5

----------- ---------  ---------- -----  ----

                36206                    9


评论

共有 条评论