参考:

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的更多相关文章

  1. Qt4.7文档翻译:Qt样式单参考,Qt Style Sheets Reference(超长,超全)

    内容目录 Qt样式单参考 可进行样式设置的部件列表 属性列表 图标列表 属性类型列表 伪状态列表 子控件列表 Qt样式单参考 Qt样式单支持各种属性.伪状态和子控件,这样使得妳能够自行设计部件的外观. ...

  2. QT样式表

    QT样式表 一.QT样式表简介 1.QT样式表简介 QSS的主要功能是使界面的表现与界面的元素分离,使得设计皮肤与界面控件分离的软件成为可能. QT样式表是允许用户定制widgets组件外观的强大机制 ...

  3. 在PyQt中构建 Python 菜单栏、菜单和工具栏

    摘要:菜单.工具栏和状态栏是大多数GUI 应用程序的常见且重要的图形组件.您可以使用它们为您的用户提供一种快速访问应用程序选项和功能的方法. 本文分享自华为云社区<Python 和 PyQt:创 ...

  4. Qt之自定义QLineEdit右键菜单

    一.QLineEdit说明 QLineEdit是单行文本框,不同于QTextEdit,他只能显示一行文本,通常可以用作用户名.密码和搜索框等.它还提供了一些列的信号和槽,方便我们使用,有兴趣的小伙伴可 ...

  5. Qt自定义菜单项

    经常会看到一些菜单的部分项是由几个按钮组成的,如酷狗.QQ.360都有类似菜单,对于常规的菜单项,图标 + 文字 实现一个事件,很容易完成,那么怎么自定义菜单项呢? Qt提供了支持,就是利用QWidg ...

  6. 处理QMenu的triggered信号时遇到的一个问题

    最近,在一个Qt程序中使用QMenu类时,遇到了一个小问题,特记录下.首先,我模仿一下问题出现的场景:假设我在做一个高大上的XX管理系统,比如说:学生信息管理系统.在这个系统中,学生的各项信息(比如: ...

  7. QT中自定义系统托盘的实现—c++语言为例

    将要介绍的是:QT中自定义系统托盘(systemtray)的一个Demo,希望能帮需要的读者快速上手. 前提假设是诸位已经知道QT中的signals .slot以及资源文件,所以关于这些不会再累述. ...

  8. 如何在pyqt中实现带动画的动态QMenu

    弹出菜单的视觉效果 QLineEdit 原生的菜单弹出效果十分生硬,而且样式很丑.所以照着Groove中单行输入框弹出菜单的样式和动画效果写了一个可以实现动态变化Item的弹出菜单,根据剪贴板的内容是 ...

  9. 关于Unity3D自定义编辑器的学习

    被人物编辑器折腾了一个月,最终还是交了点成品上去(还要很多优化都还么做).  刚接手这项工作时觉得没概念,没想法,不知道.后来就去看<<Unity5.X从入门到精通>>中有关于 ...

随机推荐

  1. ES6 & Map & hashMap

    ES6 & Map & hashMap 01 two-sum https://leetcode.com/submissions/detail/141732589/ hashMap ht ...

  2. 一、kubeadm安装

    一.官网 https://kubernetes.io/zh/docs/setup/independent/install-kubeadm/ 阿里云 kubernetes yum 仓库镜像 安装kube ...

  3. Python——Flask框架——模板

    一.渲染模板 render_template 函数把Jinja2模板引擎集成到程序中 二.Jinja2变量过滤器 过滤器名 说明 safe 渲染值是不转义 capitalize 把值得首字母转换成大写 ...

  4. Vue插件plugins的基本操作

    前面的话 本文将详细介绍Vue插件plugins的基本操作 开发插件 插件通常会为 Vue 添加全局功能.插件的范围没有限制——一般有下面几种: 1.添加全局方法或者属性,如: vue-custom- ...

  5. Asp.Net Core 输出 Word

    In one of the ASP.NET Core projects we did in the last year, we created an OutputFormatter to provid ...

  6. bzoj4152-[AMPPZ2014]The_Captain

    Description 给定平面上的n个点,定义(x1,y1)到(x2,y2)的费用为min(|x1-x2|,|y1-y2|),求从1号点走到n号点的最小费用. Input 第一行包含一个正整数n(2 ...

  7. 实验吧 WEB 猫抓老鼠

    人生的第一道CTF题目哇,鸡冻 其实只是学了一下HTTP抓包得到的都是什么,就开始上手胡搞了 题目名字叫猫抓老鼠,还疯狂暗示catch!catch!catch!catch!,就想到要用抓包其实我是因为 ...

  8. Maven使用(一)—— Maven的安装与全局配置

    一.Maven安装 Maven的安装步骤: 1.Maven官网(http://maven.apache.org/)下载压缩包,解压缩,当前最新版本是apache-maven-3.5.3-bin.zip ...

  9. python 模块之-pickle

    Pickle的问题和所有其他编程语言特有的序列化问题一样,就是它只能用于Python,并且可能不同版本的Python彼此都不兼容,因此,只能用Pickle保存那些不重要的数据,不能成功地反序列化也没关 ...

  10. BZOJ4946[Noi2017]蔬菜——线段树+堆+模拟费用流

    题目链接: [Noi2017]蔬菜 题目大意:有$n$种蔬菜,每种蔬菜有$c_{i}$个,每种蔬菜每天有$x_{i}$个单位会坏掉(准确来说每天每种蔬菜坏掉的量是$x_{i}-$当天这种蔬菜卖出量), ...