QT开发之QSS控件

江枫思渺然 提交于 2019-12-18 04:00:34

1、多选按钮


        ui->checkBox->setStyleSheet("QCheckBox {"
                                       "spacing: 5px;"
                                       "font-size: 14px;"
                                       "color: rgb(24, 220, 88);}"
                                    "QCheckBox::indicator { "
                                       "width: 16px;"
                                       "height: 16px;}"
                                    // 未选中时正常状态
                                   "QCheckBox::indicator::unchecked {"   
                                       "image: url(:/1.png);}"
                                    // 未选中时,鼠标悬停时的状态
                                   "QCheckBox::indicator:unchecked:hover {"   
                                       "image: url(:/2.png);}"
                                    //未选中时,按下时的状态
                                   "QCheckBox::indicator:unchecked:pressed {"   
                                       "image: url(:/3.png);}"
                                    // 选中时的状态
                                   "QCheckBox::indicator::checked {"   
                                       "image: url(:/4.png);}"
                                    // 选中时,鼠标悬停状态
                                  "QCheckBox::indicator:checked:hover {"   
                                       "image: url(:/5.png);}"
                                    // 选中时,鼠标下按时的状态
                                   "QCheckBox::indicator:checked:pressed {" 
                                       "image: url(:/6.png);}"
        );

单选按钮将QCheckBox替换为QRadioButton

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!