当前位置:网站首页>Notes on setting qccheckbox style
Notes on setting qccheckbox style
2022-06-26 09:01:00 【liji_ digital】
Catalog
Mission
Display with sliding buttons checkbox Checked and unchecked status of .


Be careful 1
In order to display the rounded corner feature of the button , The suggested picture format is png Format , This makes the image outside the rounded corner transparent .
Be careful 2
You can qss File configuration qcheckbox The style of , You can also call... Directly in your code setStyleSheet function . The latter is used here .
Be careful 3
The picture is posted on QCheckbox On the square of .QCheckbox The text on the right is unaffected .
And the default. QCheckbox The square of is too small . The icon is not very clear . So you should use the following qss Configure the size of the square :
QCheckBox::indicator {width: 90px; height: 60px;}Be careful 4
A great deal of qss In the example , The image is referenced as a resource file , So add the picture qt In our resources . But this example does not add images to the resources . Instead, put the image directly into the build directory .setStyleSheet The referenced image path is relative to the build directory .
Such as the following path , Is under the build directory asset

setStyleSheet The path inside is also relative to the build directory :
QCheckBox::indicator:unchecked {border-image: url(./asset/on1.png)}If you use qss File configuration style , And you don't want to add pictures to resources , Then qss References within documents are relative to qss The path to the directory where the file is located .
Be careful 5
The following three lines should be configured in the same setStyleSheet Use in , It is not possible to use separate setStyleSheet One by one call , In that case , The previous call is invalid .
ui->checkBox->setStyleSheet("QCheckBox::indicator {width: 90px; height: 60px;}"
"QCheckBox::indicator:unchecked {border-image: url(./asset/on1.png) 0 0 0 0 stretch stretch}"
"QCheckBox::indicator:checked {border-image: url(./asset/off1.png) 0 0 0 0 stretch stretch}");
effect

The complete source code and executable program have been uploaded to my resources be based on qt The program , Demonstrated how to pass through setStyleSheet To configure checkbox Appearance of the button .-C++ Document resources -CSDN download
边栏推荐
- Pytorch build progression
- 1.26 pytorch learning
- Reverse crawling verification code identification login (OCR character recognition)
- Pytorch neural network
- Use of PCL
- SRv6----IS-IS扩展
- Line detection_ nanyangjx
- Principle of playing card image segmentation
- docker安装redis
- Convert verification code image to tfrecord file
猜你喜欢

Section IV HQL execution process

反爬之验证码识别登录 (OCR字符识别)

什么是乐观锁,什么是悲观锁

深度学习论文阅读目标检测篇(七)中文版:YOLOv4《Optimal Speed and Accuracy of Object Detection》

基于SSM的毕业论文管理系统

yolov5进阶之零环境快速创建及测试

Data warehouse (1) what is data warehouse and what are the characteristics of data warehouse

修复小程序富文本组件不支持video视频封面、autoplay、controls等属性问题

爬虫 对 Get/Post 请求时遇到编码问题的解决方案

Yolov5进阶之四训练自己的数据集
随机推荐
In automated testing, there are three commonly used waiting methods: sleep, implicitly\wait, and expected\u conditions
ROS learning notes (5) -- Exploration of customized messages
PD快充磁吸移动电源方案
外部排序和大小堆相关知识
Yolov5进阶之五GPU环境搭建
1.27 pytorch learning
Summary of common instructions for arm assembly
1.21 study gradient descent and normal equation
keras_ Callback function summary
WBC learning notes (I): manually push WBC formula
How to use the least money to quickly open the Taobao traffic portal?
Efficiency thesis Reading 1
Section IV HQL execution process
[300+ continuous sharing of selected interview questions from large manufacturers] column on interview questions of big data operation and maintenance (I)
[program compilation and pretreatment]
Clion installation + MinGW configuration + opencv installation
基于SSM的毕业论文管理系统
Google Chrome collection
【微积分】拉格朗日乘子法
百度小程序富文本解析工具bdParse