参考:

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. qtp 自动货测试桌面程序-笔记(使用参数 parameters)

    dtGlobalSheet:运行整个test时候使用的参数(心得:可以将公共使用的测试数据放于全局表格中,所有action脚本都可以使用同一个数据,如供应商.客户.商品) dtActionSheet: ...

  2. TField OnValidate 事件

    Occurs just before the data is written to the record buffer. Write an OnValidate event handler to va ...

  3. Java之指定Junit测试方法的执行顺序举例

    问题描述: 大家都知道使用JUnit进行测试的时候,方法的执行顺序不是按照编写的先后顺序执行的,那么如何控制Junit的执行顺序呢? 解决方法: 在测试类上加 @FixMethodOrder 注解即可 ...

  4. jq的$.each()方法

    jq的$.each()方法: 语法:jQuery.each(object, [callback]) 回调函数拥有两个参数:第一个为对象的成员或数组的索引,第二个为对应变量或内容.如果需要退出 each ...

  5. ADO.NET工具类(三)

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...

  6. 训练赛-Eyad and Math

    题意:给你四个数,求出a^b是否小于c^d,是的话输出<,否则输出>; 思路:因为数据很大,所以我们需要降低数据的规模,比如用一个log10()函数,这就能解决了,注意,要用scanf输入 ...

  7. Android 根据版本号更新

    1 读取android 版本号 具体文件位置: app下 build.gradle文件 versionCode和 versionName defaultConfig { versionCode 1 v ...

  8. C - A Simple Problem with Integers POJ - 3468 线段树模版(区间查询区间修改)

    参考qsc大佬的视频 太强惹 先膜一下 视频在b站 直接搜线段树即可 #include<cstdio> using namespace std; ; int n,a[maxn]; stru ...

  9. linux下后台启动springboot项目

    linux下后台启动springboot项目 我们知道启动springboot的项目有三种方式: 运行主方法启动 使用命令 mvn spring-boot:run”在命令行启动该应用 运行“mvn p ...

  10. nginx+php使用open_basedir限制站点目录防止跨站

    以下三种设置方法均需要PHP版本为5.3或者以上.方法1)在Nginx配置文件中加入 fastcgi_param PHP_VALUE "open_basedir=$document_root ...