当前位置:网站首页>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
- WebRTC音视频采集和播放示例及MediaStream媒体流解析
- uniapp微信登录返显用户名和头像
- Antd component upload uploads xlsx files and reads the contents of the files
- 数据分析学习记录--用EXCEL完成简单的单因素方差分析
- Golang面试整理 三 简历如何书写
- Jerry's built-in shutdown current is 1.2ua, and then it can't be turned on by long pressing [chapter]
- 从2022年Q1财报看携程的韧性和远景
- 送给即将工作的自己
- 小鹏P7出事故,安全气囊未弹出,这正常吗?
猜你喜欢
![[chestnut sugar GIS] how does global mapper batch produce ground contour lines through DSM](/img/5d/c23ec16df6ce8d78207b635f59dc20.png)
[chestnut sugar GIS] how does global mapper batch produce ground contour lines through DSM

数据分析学习记录--用EXCEL完成简单的单因素方差分析

Niuke network: maximum submatrix

kubernetes 使用主机名将 pod 分配在指定节点上

情感对话识别与生成简述
![[chestnut sugar GIS] ArcMap - how to batch modify the font, color, size, etc. of annotation elements](/img/b1/1fae909fb6a9231096a93d741d6426.png)
[chestnut sugar GIS] ArcMap - how to batch modify the font, color, size, etc. of annotation elements

Jatpack------LiveData

全面解析分享购商业模式逻辑?分享购是如何赋能企业
![[羊城杯2020]easyphp](/img/12/da28f738e50e625b0a66a94af3703d.png)
[羊城杯2020]easyphp

中国信通院、清华大学、腾讯安全,云原生安全产学研用强强联合!
随机推荐
杰理之、产线装配环节【篇】
Construction of Hisilicon 3559 universal platform: draw a frame on the captured YUV image
Niuke: Dragon and dungeon games
Lambda expression: an article takes you through
严守工期,确保质量,这家AI数据标注公司做到了!
电路设计者常用的学习网站
LeetCode 968. 监控二叉树
[leetcode] most elements [169]
Jerry's prototype will trigger shutdown after multiple touches [chapter]
【喜欢的诗词】好了歌
【硬件】标准阻值的由来
[LeetCode] 多数元素【169】
Baidu AI Cloud - create a face recognition application
Learning records of data analysis (II) -- simple use of response surface method and design expert
从2022年Q1财报看携程的韧性和远景
Solve the error of changing the selected file when uploading excel file. Net:: err_ UPLOAD_ FILE_ CHANGED
Array advanced improvement
The threshold value of fusing proportion cannot be changed with sentinel, and setting the slow call proportion has no effect
【板栗糖GIS】arcscene—如何做出有高度的高程图
JS syntax ES6, ES7, es8, es9, ES10, es11, ES12 new features (Abstract)