Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of realizing Linear loading Bar with Qt Custom Control

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the "Qt custom control to achieve linear loading bar method", in the daily operation, I believe that many people have doubts in the Qt custom control to achieve linear loading bar method, the editor consulted all kinds of data, sorted out a simple and easy-to-use operation method, hope to answer the "Qt custom control to achieve linear loading bar method" of the doubt to help! Next, please follow the editor to study!

Idea: first draw a line, then rotate the coordinate system and then draw other lines, the lines that highlight the color can be drawn dead and then rotated, or you can increase the angle to make the specific line drawing highlight the color (this is used here).

LoadingBarA::LoadingBarA (QWidget * parent): QWidget (parent) {timer = new QTimer (this); / / timer timer- > setInterval (50); connect (timer,QTimer::timeout,this, [=] () {if (pointRectwidth (); 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); float degree = 360.0bp count; / / rectCount: how many lines for (int I = 0 Qt::NoPen (); painter- > setPen (Qt::NoPen); painter- > setBrush (color); QRect rect (arcLength,-rectHeight/2,rectWidth,rectHeight); painter- > drawRoundedRect (rect,rectHeight/2,rectHeight/2); painter- > restore ();} void LoadingBarA::setDarkColor (QColor tempColor) {this- > darkColor = tempColor; update () } void LoadingBarA::setLightColor (QColor lightColor) {this- > lightColor = lightColor; update ();} void LoadingBarA::setRectWidth (int l) {this- > rectWidth = 1; update ();} void LoadingBarA::setRectHeight (int l) {this- > rectHeight = 1; update ();} void LoadingBarA::setArcLength (int l) {this- > arcLength = 1; update ();} void LoadingBarA::setRectCount (int l) {this- > rectCount = 1; update () } void LoadingBarA::startLoading () {/ / set start timer- > start ();} at this point, the study on "the method of Qt custom control to achieve linear loading bar" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report