当前位置:网站首页>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);
边栏推荐
猜你喜欢
Local dealers play the community group purchase mode and share millions of operations
小鹏P7出事故,安全气囊未弹出,这正常吗?
Qt QProgressBar详解
从2022年Q1财报看携程的韧性和远景
分享 10 个 JS 闭包面试题(图解),进来看看你能答对多少
Graphic view frame
uniapp微信登录返显用户名和头像
严守工期,确保质量,这家AI数据标注公司做到了!
Hanging mirror security won four global infosec awards on rsac2022
成功改变splunk 默认URL root path
随机推荐
[leetcode] there are duplicate elements [217]
Antd component upload uploads xlsx files and reads the contents of the files
数组进阶提高
全面解析分享购商业模式逻辑?分享购是如何赋能企业
PMP project integration management
go 条件变量
世界环境日 | 周大福用心服务推动减碳环保
【板栗糖GIS】arcmap—如何批量修改注记要素的字体,颜色,大小等
地方经销商玩转社区团购模式,百万运营分享
E-commerce system microservice architecture
Qt QScrollArea
`${}`的用法
Jerry's charge unplugged, unable to touch the boot [chapter]
首批 | 腾讯云完成国内首个云原生安全成熟度评估
Mask R-CNN
Niuke network: maximum submatrix
用sentinel熔断比例阈值改不了,设置慢调用比例没效果
Pytorch training CPU usage continues to grow (Bug)
位的高阶运算
Introduction and response to high concurrency