当前位置:网站首页>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
边栏推荐
- Data warehouse (1) what is data warehouse and what are the characteristics of data warehouse
- 【云原生 | Kubernetes篇】深入万物基础-容器(五)
- yolov5进阶之零环境快速创建及测试
- Exploration of webots and ROS joint simulation (I): software installation
- HDU - 6225 Little Boxes(__int128的使用)
- isinstance()函数用法
- 基于SSM的电脑商城
- WBC learning notes (II): practical application of WBC control
- The solution of positioning failure caused by framework jump
- 1.17 daily improvement of winter vacation learning (frequency school and Bayesian school) and maximum likelihood estimation
猜你喜欢

Principle of playing card image segmentation

浅谈一下Type-C接口发展历程

【300+精选大厂面试题持续分享】大数据运维尖刀面试题专栏(一)

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

Bezier curve learning

Mongodb分片环境搭建和验证(redis期末大作业)

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

SQL learning experience (II): question brushing record

【程序的编译和预处理】

Install Anaconda + NVIDIA graphics card driver + pytorch under win10_ gpu
随机推荐
Some commands for remote work
力扣399【除法求值】【并查集】
[Matlab GUI] key ID lookup table in keyboard callback
拦截器与过滤器的实现代码
攔截器與過濾器的實現代碼
Fast construction of neural network
PD快充磁吸移动电源方案
Line detection_ nanyangjx
深度学习论文阅读目标检测篇(七)中文版:YOLOv4《Optimal Speed and Accuracy of Object Detection》
HDU - 6225 little boxes (\u int128)
上下架和橱窗推荐如何设置,优化过程需要注意的地方
[qnx hypervisor 2.2 user manual]12.2 terminology (II)
Partial summary of 45 lectures on geek time MySQL
uniapp用uParse实现解析后台的富文本编辑器的内容及修改uParse样式
反爬之验证码识别登录 (OCR字符识别)
Sqoop merge usage
Mongodb分片环境搭建和验证(redis期末大作业)
Yolov5进阶之一摄像头实时采集识别
Games104 Lecture 12 游戏引擎中的粒子和声效系统
How to set the shelves and windows, and what to pay attention to in the optimization process