当前位置:网站首页>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);
边栏推荐
- 泛型与反射,看这篇就够了
- Generics and reflection, this is enough
- Golang的学习路线
- 剑指 Offer II 099. 最小路径之和-双百代码
- Construction of Hisilicon 3559 universal platform: draw a frame on the captured YUV image
- Jatpack------LiveData
- `Usage of ${}`
- Dahua cloud native load balancing article - the passenger flow of small restaurants has increased
- Jerry's prototype has no touch, and the reinstallation becomes normal after dismantling [chapter]
- 最小生成树 Minimum Spanning Tree
猜你喜欢
数据分析学习记录--用EXCEL完成简单的单因素方差分析
数据标注典型案例,景联文科技如何助力企业搭建数据方案
严守工期,确保质量,这家AI数据标注公司做到了!
悬镜安全在RSAC2022上斩获Global InfoSec Awards四项大奖
Niuke: Dragon and dungeon games
泛型与反射,看这篇就够了
WebRTC音视频采集和播放示例及MediaStream媒体流解析
Comprehensively analyze the logic of the shared purchase business model? How sharing purchase empowers Enterprises
Splunk audit 的设定
AES高级加密协议的动机阐述
随机推荐
2016. 增量元素之间的最大差值
stop slave卡住--事务的事件没有复制完整
地平线2022年4月最新方案介绍
odoo13搭建医院HRP环境(详细步骤)
杰理之、产线装配环节【篇】
Freshman learning sharing
Jielizhi, production line assembly link [chapter]
位的高阶运算
全面解析分享购商业模式逻辑?分享购是如何赋能企业
悬镜安全在RSAC2022上斩获Global InfoSec Awards四项大奖
[leetcode] number of palindromes [9]
[chestnut sugar GIS] ArcMap - how to batch modify the font, color, size, etc. of annotation elements
Solve the error of changing the selected file when uploading excel file. Net:: err_ UPLOAD_ FILE_ CHANGED
Stop slave is stuck -- the event of the transaction is not copied completely
高并发介绍及应对
DTM distributed transaction manager PHP collaboration client V0.1 beta release!!!
E-commerce system microservice architecture
[Luogu p1541] tortoise chess [DP]
P7072 [csp-j2020] live broadcast Award
Jericho's thimble reaction when directly touching the prototype is abnormal [chapter]