自定义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从入门到精通>>中有关于 ...
随机推荐
- WPF Image控件的绑定
在我们平时的开发中会经常用到Image控件,通过设置Image控件的Source属性,我们可以加载图片,设置Image的source属性时可以使用相对路径也可以使用绝对路径,一般情况下建议使用绝对路径 ...
- 莫烦theano学习自修第二天【激励函数】
1. 代码如下: #!/usr/bin/env python #! _*_ coding:UTF-8 _*_ import numpy as np import theano.tensor as T ...
- 根据request获取请求客户端的外网ip
//根据request获取外网ip private static String getRemoteIp(HttpServletRequest request) { //x-forwarded-for: ...
- 前端传递给后端且通过cookie方式,尽量传递id
前端传递给后端且通过cookie方式,尽量传递id
- 前端部分-CSS基础介绍
CSS介绍 CSS(Cascading Style Sheet,层叠样式表)定义如何显示HTML元素.也就是定义相应的标签语言来定制显示样式达到一定的显示效果. 每个CSS样式由两个组成部分:选择器和 ...
- oracle的用户账号密码设置
1. 可以用sqlplus system/你输入的密码 可以用sqlplus /nolog 可以用sqlplus /as sysdba2. @你scott.sql的路径3. 修改你的账号 alter ...
- AIM Tech Round 4 Div. 1
A:显然最优方案是对所形成的置换的每个循环排个序. #include<iostream> #include<cstdio> #include<cmath> #inc ...
- Luogu5205 【模板】多项式开根(NTT+多项式求逆)
https://www.cnblogs.com/HocRiser/p/8207295.html 安利! 写NTT把i<<=1写成了i<<=2,又调了一年.发现我的日常就是数组开 ...
- python成长之路一
1,计算机基础 CPU:中央处理器,相当于人类的大脑,运算中心,控制中心. 内存:暂时储存数据,与CPU交互,8G,16G,32G,64G § 优点:读取速度快. § 缺点:容量小,造价高,断电即消失 ...
- thinkphp5.0.7 &===composer更新===& thinkphp5.0.9 debug “controller not found”
当thinkphp5.0.7更新到最新版本时,问题来了... 控制类加载不了. 上线版本出现这个情况,也就悲哀了.====== 那么这种问题主要是因为 composer 没有合理的使用: 详细参考:如 ...