当前位置:网站首页>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
边栏推荐
- Yolov5 advanced camera real-time acquisition and recognition
- 实践是成为网工最快的方法,网络工程师实战项目整理
- Data warehouse (1) what is data warehouse and what are the characteristics of data warehouse
- Summary of common instructions for arm assembly
- ImportError: ERROR: recursion is detected during loading of “cv2“ binary extensions. Check OpenCV in
- Euler function: find the number of numbers less than or equal to N and coprime with n
- Selenium 搭建 Cookies池 绕过验证反爬登录
- 1.20 study univariate linear regression
- Mongodb分片环境搭建和验证(redis期末大作业)
- dedecms小程序插件正式上线,一键安装无需任何php或sql基础
猜你喜欢

Computer mall based on SSM

Fourier transform of image

Construction and verification of mongodb sharding environment (redis final assignment)

【云原生 | Kubernetes篇】深入万物基础-容器(五)

设置QCheckbox 样式的注意事项

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

Digital image processing learning (II): Gaussian low pass filter

Drawing with MATLAB (2) -- color ring

Live review | smardaten lihongfei interprets the Research Report on China's low / no code industry: the wind direction has changed

Matlab drawing checkerboard (camera calibration)
随机推荐
docker安装redis
小程序首页加载之前加载其他相关资源或配置(小程序的promise应用)
Digital image processing learning (II): Gaussian low pass filter
20220623 Adobe Illustrator入门
Fourier transform of image
Intra class data member initialization of static const and static constexpr
Summary of mobile terminal lightweight model data
XSS 跨站脚本攻击
关于极客时间 | MySQL实战45讲的部分总结
[QNX Hypervisor 2.2用户手册]12.2 术语(二)
Polka lines code recurrence
phpcms v9手机访问电脑站一对一跳转对应手机站页面插件
SRv6----IS-IS扩展
编程训练7-日期转换问题
Backward usage
commonJS和ES6模块化的区别
[300+ continuous sharing of selected interview questions from large manufacturers] column on interview questions of big data operation and maintenance (I)
1.Intro_ Math (white board derivation and reprint of station B)
WBC learning notes (II): practical application of WBC control
Exploration of webots and ROS joint simulation (I): software installation