当前位置: 首页 > news >正文

QSS 用法介绍

      使用qt写程序,总要有界面,而美工给程序猿的设计总是那么美轮美奂,那么该怎么样将效果图转化为实际图?

qt借鉴css经验,设计出自己的qss。

     拿实例说话吧:

1、

QPushButton#evilButton  { background-color: red }


2、

QPushButton#evilButton  {
    background-color: red;
    border-style: outset;
    border-width: 2px;
    border-color: beige;
}


3、
    QPushButton#evilButton  {
        background-color: red;
        border-style: outset;
        border-width: 2px;
        border-radius: 10px;
        border-color: beige;
        font: bold 14px;
        min-width: 10em;
        padding: 6px;
    }



     不知你看出区别了没有,也不知你看到他的用处没有。
如果没有那么这里一定有你想要的:
推荐1:
http://thesmithfam.org/blog/2009/09/10/qt-stylesheets-tutorial/
推荐2:
http://qt-project.org/doc/qt-4.7/stylesheet-examples.html
推荐3:
http://qt-project.org/doc/qt-4.8/stylesheet-reference.html



qcolor颜色名称:


qframe结构图:


例子一:

background-color: red;

border-style: outset;

border-width: 2px;

border-radius: 10px;

border-color: beige;

font: bold 14px;

min-width: 10em;

padding: 6px;


例子二:

QPushButton:pressed  {
        background-color: rgb(0, 224, 0);
        border-style: inset;
    }
    QPushButton:hover  {
        background-color: rgb(0, 224, 240);
        border-style: inset;
    }
鼠标没有经过按钮时:

鼠标经过时:


伪目标:

Pseudo-StateDescription
:active 激活时
:adjoins-item This state is set when the ::branch of a QTreeView is adjacent to an item.
:alternate 多选择
:bottom 底部
:checked 选择状态
:closable 可关闭
:closed 关闭状态
:default 默认
:disabled 无效状态
:editable 可编辑的
:edit-focus The item has edit focus (See QStyle::State_HasEditFocus). This state is available only for Qt     Extended applications.
:enabled The item is enabled.
:exclusive The item is part of an exclusive item group. For example, a menu item in a exclusiveQActionGroup.
:first The item is the first (in a list). For example, the first tab in a QTabBar.
:flat The item is flat. For example, a flat QPushButton.
:floatable The items can be floated. For example, the QDockWidget has theQDockWidget::DockWidgetFloatable feature turned on.
:focus The item has input focus.
:has-children The item has children. For example, an item in a QTreeView that has child items.
:has-siblings The item has siblings. For example, an item in a QTreeView that siblings.
:horizontal The item has horizontal orientation
:hover The mouse is hovering over the item.
:indeterminate The item has indeterminate state. For example, a QCheckBox or QRadioButton ispartially checked.
:last The item is the last (in a list). For example, the last tab in a QTabBar.
:left The item is positioned at the left. For example, a QTabBar that has its tabs positioned atthe left.
:maximized The item is maximized. For example, a maximized QMdiSubWindow.
:middle The item is in the middle (in a list). For example, a tab that is not in the beginning or theend in a QTabBar.
:minimized The item is minimized. For example, a minimized QMdiSubWindow.
:movable The item can be moved around. For example, the QDockWidget has theQDockWidget::DockWidgetMovable feature turned on.
:no-frame The item has no frame. For example, a frameless QSpinBox or QLineEdit.
:non-exclusive The item is part of a non-exclusive item group. For example, a menu item in a non-exclusive QActionGroup.
:off For items that can be toggled, this applies to items in the "off" state.
:on For items that can be toggled, this applies to widgets in the "on" state.
:only-one The item is the only one (in a list). For example, a lone tab in a QTabBar.
:open The item is in the open state. For example, an expanded item in a QTreeView, or aQComboBox or QPushButton with an open menu.
:next-selected The next item (in a list) is selected. For example, the selected tab of a QTabBar is next tothis item.
:pressed The item is being pressed using the mouse.
:previous-selected The previous item (in a list) is selected. For example, a tab in a QTabBar that is next tothe selected tab.
:read-only The item is marked read only or non-editable. For example, a read only QLineEdit or anon-editable QComboBox.
:right The item is positioned at the right. For example, a QTabBar that has its tabs positionedat the right.
:selected The item is selected. For example, the selected tab in a QTabBar or the selected item in aQMenu.
:top The item is positioned at the top. For example, a QTabBar that has its tabs positioned atthe top.
:unchecked The item is unchecked.
:vertical The item has vertical orientation.
:window The widget is a window (i.e top level widget)


原文:http://blog.csdn.net/cgzhello1/article/details/8514113

            http://blog.csdn.net/cgzhello1/article/details/8516024


相关文章:

  • 简单算法--求一个数n的二进制形式的第i位
  • #pragam once 和 #ifndef 预编译头
  • 在线编程学习【优质的资源】
  • QSizeploicy、 QLayout-setSizeConstrain
  • C语言程序员必读的5本书
  • 一个值得Geek收藏的网站
  • 如何在QML中调用C++的方法并接收C++的信号
  • 25个非常实用的jQuery/CSS3应用组件
  • Qt for android basis , Qt Android 开发基础
  • Qt 应用程序打包教程
  • ForThirdWork-No.1:C/C++笔试题回忆并整理
  • ForThirdWork-No.2:C/C++笔试题回忆并整理
  • ForThirdWork-No.3:C/C++笔试题回忆并整理
  • 字节序相关--本地字节序和网络字节序等
  • 网络协议分层
  • Google 是如何开发 Web 框架的
  • 「前端」从UglifyJSPlugin强制开启css压缩探究webpack插件运行机制
  • 345-反转字符串中的元音字母
  • django开发-定时任务的使用
  • Docker入门(二) - Dockerfile
  • EOS是什么
  • JavaScript 事件——“事件类型”中“HTML5事件”的注意要点
  • JavaScript服务器推送技术之 WebSocket
  • JS数组方法汇总
  • Netty 4.1 源代码学习:线程模型
  • Rancher-k8s加速安装文档
  • 基于组件的设计工作流与界面抽象
  • 快速体验 Sentinel 集群限流功能,只需简单几步
  • 前端每日实战:61# 视频演示如何用纯 CSS 创作一只咖啡壶
  • 手写双向链表LinkedList的几个常用功能
  • 译有关态射的一切
  • 应用生命周期终极 DevOps 工具包
  • 用Visual Studio开发以太坊智能合约
  • - 转 Ext2.0 form使用实例
  • 小白应该如何快速入门阿里云服务器,新手使用ECS的方法 ...
  • ​力扣解法汇总1802. 有界数组中指定下标处的最大值
  • ​软考-高级-系统架构设计师教程(清华第2版)【第20章 系统架构设计师论文写作要点(P717~728)-思维导图】​
  • ​一文看懂数据清洗:缺失值、异常值和重复值的处理
  • # Swust 12th acm 邀请赛# [ K ] 三角形判定 [题解]
  • #1014 : Trie树
  • #每天一道面试题# 什么是MySQL的回表查询
  • $(function(){})与(function($){....})(jQuery)的区别
  • (7)STL算法之交换赋值
  • (Matalb时序预测)WOA-BP鲸鱼算法优化BP神经网络的多维时序回归预测
  • (二)七种元启发算法(DBO、LO、SWO、COA、LSO、KOA、GRO)求解无人机路径规划MATLAB
  • (非本人原创)我们工作到底是为了什么?​——HP大中华区总裁孙振耀退休感言(r4笔记第60天)...
  • (论文阅读笔记)Network planning with deep reinforcement learning
  • (全部习题答案)研究生英语读写教程基础级教师用书PDF|| 研究生英语读写教程提高级教师用书PDF
  • (四)docker:为mysql和java jar运行环境创建同一网络,容器互联
  • (一)【Jmeter】JDK及Jmeter的安装部署及简单配置
  • (转)机器学习的数学基础(1)--Dirichlet分布
  • (转)淘淘商城系列——使用Spring来管理Redis单机版和集群版
  • (转)用.Net的File控件上传文件的解决方案
  • . ./ bash dash source 这五种执行shell脚本方式 区别
  • ./mysql.server: 没有那个文件或目录_Linux下安装MySQL出现“ls: /var/lib/mysql/*.pid: 没有那个文件或目录”...