随笔 - 632  文章 - 17  评论 - 54  阅读 - 93万

Qt 给QCheckBox增加样式

一、概述

  做一个好看的QCheckBox

二、示例

  1.样式

复制代码
QCheckBox {
    spacing:5px; 
}

QCheckBox::indicator {
    width: 24px;
    height: 24px;
}

QCheckBox::indicator:unchecked {
    image: url(:images/icon_checked.png);
}

QCheckBox::indicator:unchecked:disabled {
    image: url(:/buttonbg/checkbox_disable);
}

QCheckBox::indicator:unchecked:hover {
    image: url(:/buttonbg/checkbox_hover);
}

QCheckBox::indicator:checked {
    image: url(:/buttonbg/checkbox_down);
}

QCheckBox::indicator:indeterminate {
    image: url(:/buttonbg/checkbox_indeterminate);
}
复制代码

  2.CheckBox.h/CheckBox.cpp

复制代码
#include "CheckBox.h"

CheckBox::CheckBox(QWidget *parent)
    : QCheckBox(parent)
{
    //这里设置一个默认的样式
    QString css = StyleHelper::getStyleSheet(StyleConfig::COMMON_EDITTEXT_DEFAULT());
    this->setStyleSheet(css);
}

CheckBox::~CheckBox()
{
}
复制代码

  3.使用

    //CheckBox
    CheckBox* cb = new CheckBox();

  4.使用

 

posted on   飘杨......  阅读(718)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
历史上的今天:
2022-11-28 SDP字段解释一览表
2013-11-28 eclipse中查看安装的所有插件,并选择性的将其卸载
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示