• Qt ------ stylesheet 样式


    1、所有的窗口组件都可以用 setStyleSheet() 设置样式

    2、使用样式,显示效果可以不受平台影响,比如保证window 7 和 linux 显示效果是一样的

    QVariant

     

     

    如果 style.qss 和 icon 在同一个 res.qrc,修改 style.qss 的内容不会更新到显示效果上,单独建一个XXX.qrc 就可以了

    style.qss 改为 style.css 更好,因为 XXX.css 使用 Qt creator 或者 Notepad++ 编辑,关键字可以高亮

    添加到 Resources 的好处是可以把 XXX.qss 编译进exe文件

    样式语法:

    QPushButton, QLineEdit, QComboBox { color: red; background-color: white }

    样式规则由 selector 和 declaration 两部分组成,QPushButton 是 selector;color: red 是 declaration;color 是 property

    在 Qt assistant 里“Qt style sheets reference”的“List of Properties”介绍哪些 properties 可以用在哪些控件上

    部分 property 含义解释:

    selection-color:被选中的文字的颜色

    selection-background-color:被选中的字体的背景颜色

    border-radius:把长方形的四个直角圆角化

    好看样式收集:

    QPushButton {
        border-left-width: 0px;
        border-top-width: 0px;
        border-bottom-width: 3px;
        border-right-width: 3px;
        border-style: outset;
        border-radius: 5px;
        border-color: black;
    }
    QPushButton:hover {
        border-color: red;
    }
    QPushButton:pressed {
        border-left-width: 3px;
        border-top-width: 3px;
        border-bottom-width: 0px;
        border-right-width: 0px;
        border-color: black;
    }
  • 相关阅读:
    onload事件addLoadEvent函数
    Struts 2读书笔记Struts 2知识总结
    oraclehttp://localhost:5560/isqlplus 打不开的解决方案
    Struts 2读书笔记拦截器之示例:使用拦截器完成权限控制
    使用定时器实现弹弹球
    Servlet过滤器大全
    java面试大全
    sql学习笔记
    java学习笔记
    JSP快速入门教程——全十讲
  • 原文地址:https://www.cnblogs.com/god-of-death/p/7782947.html
Copyright © 2020-2023  润新知