当前位置:网站首页>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
边栏推荐
- Playing card image segmentation
- 9. code generation
- 关于小程序tabbar不支持传参的处理办法
- 20220623 getting started with Adobe Illustrator
- phpcms小程序接口新增万能接口get_diy.php
- 1.Intro_ Math (white board derivation and reprint of station B)
- Yolov5进阶之一摄像头实时采集识别
- Graduation thesis management system based on SSM
- Some commands for remote work
- Drawing with MATLAB (1)
猜你喜欢

【程序的编译和预处理】

Matlab drawing checkerboard (camera calibration)

Principle of playing card image segmentation

Yolov5 advanced camera real-time acquisition and recognition

唯品会工作实践 : Json的deserialization应用

百度小程序富文本解析工具bdParse

Object extraction_ nanyangjx

Segmentation of structured light images using segmentation network

Computer mall based on SSM

phpcms v9手机访问电脑站一对一跳转对应手机站页面插件
随机推荐
HDU - 6225 Little Boxes(__int128的使用)
自动化测试中,三种常用的等待方式,强制式(sleep) 、 隐式 ( implicitly_wait ) 、显式(expected_conditions)
cookie session 和 token
Principle of playing card image segmentation
MPC learning notes (I): push MPC formula manually
Euler function: find the number of numbers less than or equal to N and coprime with n
phpcms小程序接口新增万能接口get_diy.php
拦截器与过滤器的实现代码
Trimming_ nanyangjx
phpcms v9去掉phpsso模块
Sqoop merge usage
XSS 跨站脚本攻击
Machine learning (Part 2)
力扣399【除法求值】【并查集】
Isinstance() function usage
Selenium builds cookies pool to bypass authentication and anti crawl login
【300+精选大厂面试题持续分享】大数据运维尖刀面试题专栏(一)
[QNX Hypervisor 2.2用户手册]12.2 术语(二)
Ultrasonic image segmentation
Section IV HQL execution process