当前位置:网站首页>QT qpprogressbar details
QT qpprogressbar details
2022-07-02 23:01:00 【Mr.codeee】
1.QProgressBar sketch
QProgressBar Provides a horizontal or vertical progress bar , have access to setMinimum() and setMaximum Specify the minimum and maximum steps . The current number of steps is setValue() Set up . The progress bar can be used reset() Rewind to the beginning .
2. Common methods
| void setMaximum(int maximum) | Set maximum |
| void setMinimum(int minimum) | Set minimum |
| void setRange(int minimum, int maximum) | set range , Maximum 、 minimum value |
| void setValue(int value) | set currency |
| void reset() | Reset |
| void setOrientation(Qt::Orientation) | Set the direction , vertical , level |
| void setAlignment(Qt::Alignment alignment) | Set alignment , In the middle , Left 、 Right |
| void setTextVisible(bool visible) | Set whether the progress bar text is displayed |
| void setInvertedAppearance(bool invert) | Set positive 、 back |
| void setFormat(const QString &format) | Set the text display format |
3. Example , Compare progress bar

p1 Set as follows , Normal settings .
ui->progressBar1->setMinimum(0);
ui->progressBar1->setMaximum(100);
ui->progressBar1->setValue(50);
ui->progressBar1->setOrientation(Qt::Horizontal);p2 Set as follows , Set the text alignment , Progress bar direction, etc .
ui->progressBar2->setMinimum(0);
ui->progressBar2->setMaximum(100);
ui->progressBar2->setValue(50);
ui->progressBar2->setOrientation(Qt::Horizontal);
ui->progressBar2->setInvertedAppearance(true);// Set opposite direction
ui->progressBar2->setFormat("%v");
ui->progressBar2->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); // Alignment mode setFormat(), There are several ways
%p% | percentage , This is the default display |
| %v | Current progress |
| %m | Total steps |
You can also directly set the displayed value , As shown in the figure below , Display decimal .

ui->progressBar1->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); // Alignment mode
ui->progressBar1->setFormat(QString("cur progress value:%1%").arg(QString::number(50.43, 'f', 2)));p3 Set as follows , Busy progress display .
Just set the maximum value 、 The minimum value is 0 That's it .
ui->progressBar3->setMinimum(0);
ui->progressBar3->setMaximum(0);4. Set up a style sheet
Here is a simple style sheet . The effect is as follows , For reference only .

QString s1 = "QProgressBar {\
border: 2px solid grey;\
border-radius: 5px;\
text-align: center;\
color:#ff0000;\
}";
QString s2 = "QProgressBar::chunk {\
background-color: #05B8CC;\
width: 20px;\
margin: 0.5px;\
}";call
ui->progressBar1->setStyleSheet(s1+s2);边栏推荐
猜你喜欢
随机推荐
Introduction and response to high concurrency
Comprehensively analyze the logic of the shared purchase business model? How sharing purchase empowers Enterprises
Go语言sqlx库操作SQLite3数据库增删改查
[leetcode] there are duplicate elements [217]
[NPUCTF2020]ezlogin xPATH注入
The threshold value of fusing proportion cannot be changed with sentinel, and setting the slow call proportion has no effect
数据标注典型案例,景联文科技如何助力企业搭建数据方案
Golang面试整理 三 简历如何书写
Generics and reflection, this is enough
To myself who is about to work
Splunk audit setting
[LeetCode] 存在重复元素【217】
Data analysis learning records -- complete a simple one-way ANOVA with Excel
How does Jerry test the wrong touch rate of keys [chapter]
QT qsplitter splitter
JS syntax ES6, ES7, es8, es9, ES10, es11, ES12 new features (Abstract)
Hanging mirror security won four global infosec awards on rsac2022
中国信通院、清华大学、腾讯安全,云原生安全产学研用强强联合!
Boot actuator - Prometheus use
小鹏P7出事故,安全气囊未弹出,这正常吗?









![加油站[问题分析->问题转换->贪心]](/img/15/5313f900abedb46ce82d8ab81af1d7.png)