自定义QMenu
参考:
http://blog.csdn.net/qq1623803207/article/details/77449884
http://blog.sina.com.cn/s/blog_a6fb6cc90101fxsc.html
待解决:把QMenu不添加到QMenuBar里就不显示Ctrl+*的这种快捷键提示怎么解决
快捷键能响应还需要把QAction添加到QToolBar里才行。
/*Qmenu Style Sheets*/
QMenu {
background-color: white; /* sets background of the menu 设置整个菜单区域的背景色,我用的是白色:white*/
border: 1px solid white;/*整个菜单区域的边框粗细、样式、颜色*/
} QMenu::item {
/* sets background of menu item. set this to something non-transparent
if you want menu color and menu item color to be different */
background-color: transparent;
padding:8px 32px;/*设置菜单项文字上下和左右的内边距,效果就是菜单中的条目左右上下有了间隔*/
margin:0px 8px;/*设置菜单项的外边距*/
border-bottom:1px solid #DBDBDB;/*为菜单项之间添加横线间隔*/
} QMenu::item:selected { /* when user selects item using mouse or keyboard */
background-color: #2dabf9;/*这一句是设置菜单项鼠标经过选中的样式*/
}
Customizing QMenu Individual items of a QMenu are styled using the 'item' subcontrol as follows: QMenu{
background-color:#ABABAB; /* sets background of the menu */
border:1px solid black;
} QMenu::item {
/* sets background of menu item. set this to something non-transparent
if you want menu color and menu item color to be different */
background-color: transparent;
} QMenu::item:selected {/* when user selects item using mouse or keyboard */
background-color:#654321;
} For a more advanced customization, use a style sheet as follows: QMenu{
background-color: white;
margin:2px;/* some spacing around the menu */
} QMenu::item {
padding:2px25px2px20px;
border:1px solid transparent;/* reserve space for selection border */
} QMenu::item:selected {
border-color: darkblue;
background: rgba(100,100,100,150);
} QMenu::icon:checked{/* appearance of a 'checked' icon */
background: gray;
border:1px inset gray;
position: absolute;
top:1px;
right:1px;
bottom:1px;
left:1px;
} QMenu::separator {
height:2px;
background: lightblue;
margin-left:10px;
margin-right:5px;
} QMenu::indicator {
width:13px;
height:13px;
} /* non-exclusive indicator = check box style indicator (see QActionGroup::setExclusive) */
QMenu::indicator:non-exclusive:unchecked{
image: url(:/images/checkbox_unchecked.png);
} QMenu::indicator:non-exclusive:unchecked:selected {
image: url(:/images/checkbox_unchecked_hover.png);
} QMenu::indicator:non-exclusive:checked{
image: url(:/images/checkbox_checked.png);
} QMenu::indicator:non-exclusive:checked:selected {
image: url(:/images/checkbox_checked_hover.png);
} /* exclusive indicator = radio button style indicator (see QActionGroup::setExclusive) */
QMenu::indicator:exclusive:unchecked{
image: url(:/images/radiobutton_unchecked.png);
} QMenu::indicator:exclusive:unchecked:selected {
image: url(:/images/radiobutton_unchecked_hover.png);
} QMenu::indicator:exclusive:checked{
image: url(:/images/radiobutton_checked.png);
} QMenu::indicator:exclusive:checked:selected {
image: url(:/images/radiobutton_checked_hover.png);
} Customizing QMenuBar QMenuBar is styled as follows: QMenuBar{
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 lightgray, stop:1 darkgray);
} QMenuBar::item {
spacing:3px;/* spacing between menu bar items */
padding:1px4px;
background: transparent;
border-radius:4px;
} QMenuBar::item:selected {/* when selected using mouse or keyboard */
background:#a8a8a8;
} QMenuBar::item:pressed {
background:#888888;
}
自定义QMenu的更多相关文章
- Qt4.7文档翻译:Qt样式单参考,Qt Style Sheets Reference(超长,超全)
内容目录 Qt样式单参考 可进行样式设置的部件列表 属性列表 图标列表 属性类型列表 伪状态列表 子控件列表 Qt样式单参考 Qt样式单支持各种属性.伪状态和子控件,这样使得妳能够自行设计部件的外观. ...
- QT样式表
QT样式表 一.QT样式表简介 1.QT样式表简介 QSS的主要功能是使界面的表现与界面的元素分离,使得设计皮肤与界面控件分离的软件成为可能. QT样式表是允许用户定制widgets组件外观的强大机制 ...
- 在PyQt中构建 Python 菜单栏、菜单和工具栏
摘要:菜单.工具栏和状态栏是大多数GUI 应用程序的常见且重要的图形组件.您可以使用它们为您的用户提供一种快速访问应用程序选项和功能的方法. 本文分享自华为云社区<Python 和 PyQt:创 ...
- Qt之自定义QLineEdit右键菜单
一.QLineEdit说明 QLineEdit是单行文本框,不同于QTextEdit,他只能显示一行文本,通常可以用作用户名.密码和搜索框等.它还提供了一些列的信号和槽,方便我们使用,有兴趣的小伙伴可 ...
- Qt自定义菜单项
经常会看到一些菜单的部分项是由几个按钮组成的,如酷狗.QQ.360都有类似菜单,对于常规的菜单项,图标 + 文字 实现一个事件,很容易完成,那么怎么自定义菜单项呢? Qt提供了支持,就是利用QWidg ...
- 处理QMenu的triggered信号时遇到的一个问题
最近,在一个Qt程序中使用QMenu类时,遇到了一个小问题,特记录下.首先,我模仿一下问题出现的场景:假设我在做一个高大上的XX管理系统,比如说:学生信息管理系统.在这个系统中,学生的各项信息(比如: ...
- QT中自定义系统托盘的实现—c++语言为例
将要介绍的是:QT中自定义系统托盘(systemtray)的一个Demo,希望能帮需要的读者快速上手. 前提假设是诸位已经知道QT中的signals .slot以及资源文件,所以关于这些不会再累述. ...
- 如何在pyqt中实现带动画的动态QMenu
弹出菜单的视觉效果 QLineEdit 原生的菜单弹出效果十分生硬,而且样式很丑.所以照着Groove中单行输入框弹出菜单的样式和动画效果写了一个可以实现动态变化Item的弹出菜单,根据剪贴板的内容是 ...
- 关于Unity3D自定义编辑器的学习
被人物编辑器折腾了一个月,最终还是交了点成品上去(还要很多优化都还么做). 刚接手这项工作时觉得没概念,没想法,不知道.后来就去看<<Unity5.X从入门到精通>>中有关于 ...
随机推荐
- shell自定义输入输出 read+echo
自定义格式输入.输出(244) 输出:echo -e 解释转义字符 -n 回车不换行 \n 新的一行,等同于回车 \t 制表符 \r 回车 \b 回退 baskspace 删除键 演示\n \ ...
- comparable和comparator
Comparable Comparable可以认为是一个内部比较器,实现了Comparable接口的类有一个特点,就是这些类是可以和自己比较的,在compareTo方法中指定具体的比较方法. comp ...
- 使用PHP进行SOCKET编程
一.SOCKET原理图 二.SOCKET常用函数 1.创建socket函数: resource socket_create ( int $domain , int $type , int $proto ...
- Java中的super()使用注意
1)super(参数):调用基类中的某一个构造函数(应该为构造函数中的第一条语句)2)this(参数):调用本类中另一种形成的构造函数(应该为构造函数中的第一条语句)3)super: 它引用当前对象的 ...
- curl 命令 从文件读取参数
-d @filename 从文件读入内容-d @- 从stdin读入内容 -x localhost:8888 加上fiddler代理 一个sample curl -K api.conf -d @b ...
- Rest模式get,put,post,delete含义与区别
POST /uri 创建 DELETE /uri/xxx 删除 PUT /uri/xxx 更新或创建 GET /uri/xxx 查看 GET操作是安全的.所谓 ...
- redis日常使用汇总--持续更新
redis日常使用汇总--持续更新 工作中有较多用到redis的场景,尤其是触及性能优化的方面,传统的缓存策略在处理持久化和多服务间数据共享的问题总是不尽人意,此时引入redis,但redis是单线程 ...
- Codeforces Round #454 Div. 1
B:考虑2*m怎么构造.因为要求相邻的数不能再相邻,容易想到黑白染色之类的东西,考虑染个色然后大概把黑点扔一边白点扔一边.显然m<=3时无解.对m>4,m为偶数时,如1 2 3 4 5 6 ...
- Vue 快速入门
Vue框架介绍 中文文档: https://cn.vuejs.org/v2/guide/ Vue是一个构建数据驱动的web界面的渐进式框架. 目标是通过尽可能简单的API实现响应式的数据绑定和组合的视 ...
- Python3入门基础--str常用方法
Python基础之String常用方法 str():将其他类型的变量转换为str类型,例如: name = 'Jack' age = 22 course = ['web','Java','mysql' ...