安陆网站的建设免费的logo网站

当前位置: 首页 > news >正文

安陆网站的建设,免费的logo网站,wordpress 代码框插件,云南企业网站开发qt-动画圆圈等待-LED数字 一、演示效果二、关键程序三、下载链接 一、演示效果 二、关键程序 #include LedNumber.h #include QLabelLEDNumber::LEDNumber(QWidget *parent) : QWidget(parent) {//设置默认宽高比setScale((float)0.6);//设置默认背景色se… qt-动画圆圈等待-LED数字 一、演示效果二、关键程序三、下载链接 一、演示效果 二、关键程序 #include LedNumber.h #include QLabelLEDNumber::LEDNumber(QWidget *parent) : QWidget(parent) {//设置默认宽高比setScale((float)0.6);//设置默认背景色setBackColor(QColor(85,85,85));//设置默认文字颜色setFrontColor(QColor(255,255,255));//设置中间线颜色setLineColor(QColor(60,60,60));//设置默认文字setText(2);//设置默认文字大小setFontSize(40);//设置默认最小尺寸this-setMinimumSize(100,100); }//********************************************** 设置部分 **************************************** //设置文字颜色 void LEDNumber::setFrontColor(const QColor color) {_frontColorcolor; }//设置背景色 void LEDNumber::setBackColor(const QColor color) {_backColorcolor; }//设置中间线颜色 void LEDNumber::setLineColor(const QColor color) {_lineColorcolor; }//设置宽高比 void LEDNumber::setScale(float scale) {_scalescale; }//设置文字 void LEDNumber::setText(QString text) {_texttext; }void LEDNumber::setFontSize(int size) {_fontSizesize; }//********************************************** 绘制部分 **************************************** void LEDNumber::resizeEvent(QResizeEvent *event) {//计算绘制区域caculateArea(); }void LEDNumber::paintEvent(QPaintEvent event) {Q_UNUSED(event)QPainter painter(this);painter.setRenderHint(QPainter::Antialiasing);//计算绘制区域 // caculateArea();//绘制背景drawBack(painter);//绘制文字drawText(painter);//绘制中间线drawLine(painter); }//计算绘制区域 void LEDNumber::caculateArea() {if((this-height()-2)_scale(this-width()-2)){_widththis-width()-2;_height_width/_scale;}else{_heightthis-height()-2;_width_height*_scale;} }//绘制背景 void LEDNumber::drawBack(QPainter painter) {QPen pen(_backColor,1);painter.setPen(pen);QPainterPath path;path.addRoundedRect(1,1,_width,_height,10,10);painter.fillPath(path,_backColor);painter.drawPath(path); }//绘制文字 void LEDNumber::drawText(QPainter painter) {QPen pen(_frontColor);painter.setPen(pen);painter.setFont(QFont(Microsoft YaHei,_fontSize,75));painter.drawText(0,0,_width,_height,Qt::AlignCenter,_text); }//绘制中间线 void LEDNumber::drawLine(QPainter painter) {QPen pen(_lineColor,3);painter.setPen(pen);painter.drawLine(1,_height/2,_width1,_height/2); } #include Loading.h #include qmath.h #include QDebugLoading::Loading(QWidget parent) : QWidget(parent),_i(0),_interval(50),_index(0) {//设置背景透明//this-setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint);//this-setAttribute(Qt::WA_TranslucentBackground, true);setDotColor(QColor(49, 177, 190));setDotCount(20);connect(timer,QTimer::timeout,this,Loading::refresh);setMaxDiameter(30);setMinDiameter(5); }//********************************************** 设置部分 ************************************ //设置点的个数 void Loading::setDotCount(int count) {_countcount; }//设置点的颜色 void Loading::setDotColor(const QColor color) {_dotColorcolor; }//开始动画 void Loading::start() {timer.setInterval(_interval);timer.start(); }//设置最大直径 void Loading::setMaxDiameter(float max) {_maxDiametermax; }//设置最小直径 void Loading::setMinDiameter(float min) {_minDiametermin; } //********************************************** 绘制部分 ************************************* //刷新界面 void Loading::refresh() {repaint(); }void Loading::resizeEvent(QResizeEvent *event) {Q_UNUSED(event)caculate(); }void Loading::paintEvent(QPaintEvent *event) {Q_UNUSED(event)QPainter painter(this);painter.setRenderHint(QPainter::Antialiasing);painter.setPen(_dotColor);painter.setBrush(_dotColor);//绘制点paintDot(painter); }//计算绘制正方形区域 void Loading::caculate() {_squareWidthqMin(this-width(),this-height());float half_squareWidth/2;_centerDistancehalf-_maxDiameter/2-1;float gap(_maxDiameter-_minDiameter)/(_count-1)/2;float angleGap(float)360/_count;locationList.clear();radiiList.clear();for(int i0;i_count;i){radiiList_maxDiameter/2-i*gap;float radianqDegreesToRadians(-angleGap*i);locationList.append(Location(half_centerDistance*qCos(radian),half-_centerDistance*qSin(radian)));} }//绘制圆点 void Loading::paintDot(QPainter painter) {for(int i0;i_count;i){painter.setPen(_dotColor);//半径float radiiradiiList.at((_index_count-i)%_count);//绘制圆点painter.drawEllipse(QPointF(locationList.at(i).x,locationList.at(i).y),radii,radii);//绘制正方形//painter.drawRect(locationList.at(i).x,locationList.at(i).y,radii,radii);//绘制文字//QFont font(Microsoft YaHei,radii*1.2,75);//painter.setFont(font);//painter.drawText(QPointF(locationList.at(i).x,locationList.at(i).y),u8霞);}_index; } #include roundprogressbar.h #include qmath.h #include QPropertyAnimation #include QDebugRoundProgressBar::RoundProgressBar(QWidget parent) :QWidget(parent),_value(0),_min(0),_max(100),_precision(0) {//设置初始角度顺时针逆时针setdefault(90,true);//设置默认外圈宽度setOutterBarWidth(18);//设置默认内圈宽度setInnerBarWidth(16);//设置默认范围setRange(0,100);//设置默认值setValue(75);//设置外圈颜色setOutterColor(QColor(233,248,248));//设置默认渐变色setInnerColor(QColor(49, 177, 190),QColor(133, 243, 244));//设置默认文字颜色setDefaultTextColor(QColor(49,177,190));//设置默认精度setPrecision(0);//设置内圈默认文字样式setInnerDefaultTextStyle(RoundProgressBar::percent); }RoundProgressBar::~RoundProgressBar() { }//********************************************** 外部接口 **************************************** //设置初始角度顺时针逆时针 void RoundProgressBar::setdefault(int startAngle,bool clockWise) {_startAnglestartAngle;_clockWiseclockWise; }//设置外圈宽度 void RoundProgressBar::setOutterBarWidth(float width) {_outterBarWidthwidth; } //设置内圈宽度 void RoundProgressBar::setInnerBarWidth(float width) {_innerBarWidthwidth; }//设置值的范围 void RoundProgressBar::setRange(float min,float max) {//todo 和value比较if(maxmin){max100;min0;}else{_maxmax;_minmin;} }//设置当前值 void RoundProgressBar::setValue(float value) {QPropertyAnimation animationnew QPropertyAnimation(this,_value);animation-setDuration(500);animation-setStartValue(_value);animation-setEndValue(value);animation-setEasingCurve(QEasingCurve::OutQuad);animation-start(); }void RoundProgressBar::_setValue(float value) {_valuevalue;repaint(); }//设置外圈颜色 void RoundProgressBar::setOutterColor(const QColor outterColor) {_outterColoroutterColor; }//设置内圈渐变色 void RoundProgressBar::setInnerColor(const QColor startColor,const QColor endColor) {_startColorstartColor;_endColorendColor; }//设置内圈渐变色 void RoundProgressBar::setInnerColor(const QColor startColor) {_startColorstartColor; }void RoundProgressBar::setDefaultTextColor(const QColor textColor) {_textColortextColor; }//设置控制 void RoundProgressBar::setControlFlags(int flags) {this-_controlFlags|flags; }//设置显示数字精度 void RoundProgressBar::setPrecision(int precision) {_precisionprecision; }//********************************************** 内部绘制部分 **************************************** void RoundProgressBar::resizeEvent(QResizeEvent *event) {//根据内外圈宽度设置控件最小大小if(_outterBarWidth_innerBarWidth)this-setMinimumSize(_outterBarWidth*8,_outterBarWidth*8);elsethis-setMinimumSize(_innerBarWidth*8,_innerBarWidth*8);//计算绘制正方形区域信息caculateSquare(); }void RoundProgressBar::paintEvent(QPaintEvent *) {QPainter painter(this);painter.setRenderHint(QPainter::Antialiasing);//绘制外圈paintOutterBar(painter);//绘制内圈paintInnerBar(painter);//绘制外圈paintDot(painter);//绘制文字paintText(painter); }//计算绘制正方形区域信息 void RoundProgressBar::caculateSquare() {int minWidthqMin(this-width(),this-height());float barWidthqMax(_outterBarWidth,_innerBarWidth);_squareWidthminWidth-barWidth-2;_squareStartbarWidth/21;_dotX_squareStart_squareWidth/2;_dotY_squareStart; }//绘制外圈 void RoundProgressBar::paintOutterBar(QPainter painter) {if(!(_controlFlagsoutterCirle))return;QPen pen;pen.setWidth(_outterBarWidth);pen.setColor(_outterColor);painter.setPen(pen);QRectF rectangle(_squareStart,_squareStart,_squareWidth,_squareWidth);//从90度开始逆时针旋转painter.drawEllipse(rectangle); }//绘制内圈 void RoundProgressBar::paintInnerBar(QPainter painter) {QPen pen;if(!(_controlFlagslinearColor))pen.setColor(_startColor);else{QLinearGradient gradient(0, 0, 0, _squareWidth);gradient.setColorAt(0, _startColor);gradient.setColorAt(1, _endColor);QBrush brush(gradient);pen.setBrush(brush);}pen.setWidth(_innerBarWidth);pen.setStyle(Qt::SolidLine);pen.setCapStyle(Qt::RoundCap);pen.setJoinStyle(Qt::RoundJoin);painter.setPen(pen);QRectF rectangle(_squareStart,_squareStart,_squareWidth,_squareWidth);//从90度开始逆时针旋转int startAngle_startAngle*16;int spanAngle(_value-_min)/(_max-_min)*36016(_clockWise?-1:1);painter.drawArc(rectangle,startAngle,spanAngle); }//绘制装饰圆点 void RoundProgressBar::paintDot(QPainter painter) {if(!(_controlFlagsdecorateDot))return;//当bar宽度小于3时便不再绘制装饰圆点if(_innerBarWidth3)return;painter.setPen(QColor(255,255,255));painter.setBrush(QColor(255,255,255));//区域为圆点绘制正方形区域painter.drawEllipse(_dotX-_innerBarWidth/6,_dotY-_innerBarWidth/6,_innerBarWidth/3,_innerBarWidth/3); }//绘制默认内置文字 void RoundProgressBar::paintText(QPainter painter) {if(!(_controlFlagsdefaultText))return;painter.setPen(_textColor);painter.setFont(QFont(Microsoft YaHei,22,75));switch (_innerDefaultTextStyle) {case value:painter.drawText(_squareStart,_squareStart,_squareWidth,_squareWidth,Qt::AlignCenter,QString::number(_value,f,_precision));break;case valueAndMax:painter.drawText(_squareStart,_squareStart,_squareWidth,_squareWidth,Qt::AlignCenter,QString::number(_value,f,_precision)/QString::number(_max,f,_precision));break;case percent:painter.drawText(_squareStart,_squareStart,_squareWidth,_squareWidth,Qt::AlignCenter,QString::number(_value/_max*100,f,_precision)%);break;default:break;} } 三、下载链接 https://download.csdn.net/download/u013083044/88864197