当前位置:网站首页>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);边栏推荐
- Learning records of data analysis (II) -- simple use of response surface method and design expert
- Comprehensively analyze the logic of the shared purchase business model? How sharing purchase empowers Enterprises
- Dahua cloud native load balancing article - the passenger flow of small restaurants has increased
- Learning Websites commonly used by circuit designers
- 从2022年Q1财报看携程的韧性和远景
- Jatpack------LiveData
- [chestnut sugar GIS] ArcScene - how to make elevation map with height
- Jerry's fast touch does not respond [chapter]
- Motivation du Protocole de chiffrement avancé AES
- LeetCode 968. 监控二叉树
猜你喜欢
随机推荐
E-commerce system microservice architecture
编辑卡顿
大一学习分享
Jerry's built-in short press and long press, no matter how long it is, it is a short press [chapter]
DTM distributed transaction manager PHP collaboration client V0.1 beta release!!!
Storage unit conversion
1px pixel compatibility of mobile terminal, 1px border
[羊城杯2020]easyphp
Array advanced improvement
World Environment Day | Chow Tai Fook serves wholeheartedly to promote carbon reduction and environmental protection
Introduction and response to high concurrency
LC173. 二叉搜索树迭代器
How does Jerry test the wrong touch rate of keys [chapter]
数据分析学习记录(二)---响应曲面法及Design-Expert的简单使用
Jatpack------LiveData
全面解析分享购商业模式逻辑?分享购是如何赋能企业
The threshold value of fusing proportion cannot be changed with sentinel, and setting the slow call proportion has no effect
剑指 Offer II 099. 最小路径之和-双百代码
easyclick,ec权朗网络验证源码
[leetcode] most elements [169]








