In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to use Qt custom control to achieve circle loading progress bar, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
Idea: draw an arc of 270 degrees, and then define a timer to rotate the coordinate system regularly to achieve the effect of rotation. The arc needs to use a gradient to achieve the effect of lighter and lighter color.
Key code: CMProcessBar1.cpp
CMProcessBar1::CMProcessBar1 (QWidget * parent): QWidget (parent), ui (new Ui::CMProcessBar1) {ui- > setupUi (this); QTimer * timer = new QTimer; connect (timer,QTimer::timeout,this,updaterRotation); / / timing rotation coordinate system timer- > start (3); / / timing 3 milliseconds} CMProcessBar1::~CMProcessBar1 () {delete ui;} void CMProcessBar1::updaterRotation () {/ / cycle 360 degree rotation coordinate system rotation++ If (rotation) {rotation = 0;} update ();} void CMProcessBar1::paintEvent (QPaintEvent * event) {/ / draw a gradual arc according to QPaintPath int width = this- > width (); int height = this- > height (); int side = qMin (width, height); QPainter painter (this); painter.setRenderHints (QPainter::Antialiasing | QPainter::TextAntialiasing); painter.translate (width / 2, height / 2); painter.scale (side / 200.0, side / 200.0) QConicalGradient gra (QPoint (0jue 0), 0); gra.setColorAt (0Magnum QColor ("# 3BB6FE")); gra.setColorAt (1Magical QColor ("# FFFFFF")); QBrush brush (gra); int radis = 40; int sider = 5; QRect rect (- radis,-radis,radis*2,radis*2); QPainterPath path; path.arcTo (rect,0, 270); QPainterPath subPath; subPath.addEllipse (rect.adjusted (sider, sider,-sider,-sider)); path = path-subPath Painter.setBrush (brush); / / QColor ("# 66CFFF") painter.setPen (Qt::NoPen); painter.rotate (rotation); painter.drawPath (path) } Thank you for reading this article carefully. I hope the article "how to use Qt custom controls to achieve circle loading progress bar" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.