The method of realizing Linear loading Bar with Qt Custom Control
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!