找传奇、传世资源到传世资源站!

qt 圆形进度条(progress.cpp)

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

qt 自定义控件
from clipboard
void MyProgreessBar::paintEvent(QPaintEvent* event){        QPainter p(this);        QRect rc = rect();    p.setRenderHint(QPainter::Antialiasing);    int barWidget = 20;    int circleX = rc.width() / 2 ;    int circleY = rc.height() / 2;    int m_persent = 20;    int m_rotateAngle = 360 * m_persent / 100;    int allAngle = 360 * 100 / 100;      int side = qMin(rc.width(), rc.height());    QRectF outRect(0, 0, side, side);    QRectF inRect(barWidget, barWidget, side - 40, side - 40);    QString valueStr = QString("%1%").arg(QString::number(m_persent));    //画外圆    //p.setPen(Qt::NoPen);    //p.setBrush(QBrush(QColor(97, 117, 118)));    //p.drawEllipse(outRect);    //p.setBrush(QBrush(QColor(255, 107, 107)));    //p.drawPie(outRect, (90 - m_rotateAngle) * 16, m_rotateAngle * 16);    //绘制圆弧背景    QPen pen;    pen.setCapStyle(Qt::RoundCap);    pen.setWidthF(20);    pen.setColor(QColor(97, 117, 118));    p.setPen(pen);    p.drawArc(inRect, 360 * 16, 360 * 16);    //绘制圆弧进度    pen.setColor(QColor(255, 107, 107));    p.setPen(pen);    p.drawArc(inRect, 0  * 16, m_rotateAngle * 16);    //画文字    QFont f = QFont("Microsoft YaHei", 15, QFont::Bold);    p.setFont(f);    p.setFont(f);    p.setPen(QColor("#555555"));    p.drawText(inRect, Qt::AlignCenter, valueStr);}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复