备案的网站换空间景德镇网站网站建设
2026/3/10 4:49:05 网站建设 项目流程
备案的网站换空间,景德镇网站网站建设,网站推广方式都有哪些,公司企业邮箱怎么查询QMenu有多个伪状态#xff1a; :selected 鼠标停留 :default 默认选中 :exclusive 单选组 :non-exclusive 非单选组 多个子控件 ::item 菜单项 ::indicator 指示器 ::separator 分割线 ::tearoff 撕裂器 ::right-arrow 右箭头 ::left-arrow 左箭头 ::scroller 滚动条 win…QMenu有多个伪状态:selected 鼠标停留:default 默认选中:exclusive 单选组:non-exclusive 非单选组多个子控件::item 菜单项::indicator 指示器::separator 分割线::tearoff 撕裂器::right-arrow 右箭头::left-arrow 左箭头::scroller 滚动条window环境下没出来调出来滚动条和左箭头所以暂且跳过吧且看图示说明一、高对比示例QSS:QMenu::item:selected{ background-color: #FF7F00; } QMenu::item:default{ background-color: #FFFF00; } QMenu::item:exclusive:checked{ background-color: #00FF00; } QMenu::item:exclusive:unchecked{ background-color: #00FFFF; } QMenu::item:non-exclusive:checked{ background-color: #0000FF; } QMenu::item:non-exclusive:unchecked{ background-color: #8B00FF; } QMenu::indicator{ background-color: red; } QMenu::separator { background: lightblue; } QMenu::tearoff{ background: #FF1493; } QMenu::scroller{ background: #8B4513; } QMenu::right-arrow{ background: black; }菜单代码QAction* act; QMenu* menu new QMenu(this); menu-setTearOffEnabled(true); QActionGroup* g1 new QActionGroup(this); g1-setExclusive(true); QMenu *subMenu1 new QMenu(查看, this); act subMenu1-addAction(大图标); act-setCheckable(true); act-setChecked(true); act-setActionGroup(g1); act subMenu1-addAction(中图标); act-setCheckable(true); act-setActionGroup(g1); act subMenu1-addAction(小图标); act-setCheckable(true); act-setActionGroup(g1); subMenu1-addSeparator(); QActionGroup* g2 new QActionGroup(this); g2-setExclusive(false); act subMenu1-addAction(自动排列); act-setCheckable(true); act-setChecked(true); act-setActionGroup(g2); act subMenu1-addAction(将图标与网格对齐); act-setCheckable(true); act-setActionGroup(g2); menu-addMenu(subMenu1); menu-addAction(排序方式); act menu-addAction(刷新); menu-setDefaultAction(act); menu-addSeparator(); menu-addAction(撤销复制\tCtrlZ); QMenu *subMenu2 new QMenu(新建, this); subMenu2-setProperty(_q_menu_scrollable, true); subMenu2-addSection(文档类型); subMenu2-addAction(word文档); subMenu2-addAction(文本文档); subMenu2-addSection(压缩类型); subMenu2-addAction(tar文件); subMenu2-addAction(rar文件); subMenu2-addAction(zip文件); subMenu2-addSection(其它类型); for(int i0; i50;i) subMenu2-addAction(QString(其它%1).arg(i)); menu-addMenu(subMenu2); menu-addSeparator(); menu-addAction(显示设置); menu-addAction(个性化); menu-exec(QCursor().pos());二、 简约样式示例QMenu { background-color: #ffffff; color: #333333; border: 1px solid #cccccc; padding: 6px 0; } QMenu::item { padding: 7px 30px 7px 18px; margin: 0 6px; } QMenu::item:selected { background-color: #e3f2fd; color: #1976d2; } QMenu::item:disabled { color: #b0b0b0; } QMenu::separator { height: 1px; background-color: #e0e0e0; margin: 5px 10px; }三、 自定义阴影关键代码设置//自定义阴影 void setMenuShadow(QMenu* menu) { menu-setWindowFlags(menu-windowFlags() | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint); menu-setAttribute(Qt::WA_TranslucentBackground, true); QGraphicsDropShadowEffect* shadow new QGraphicsDropShadowEffect; shadow-setColor(QColor(255, 0, 0, 80)); shadow-setBlurRadius(10); shadow-setOffset(4, 4); menu-setGraphicsEffect(shadow); }QSS增加margin设置四、 菜单添加控件只是把一个原始QLineEdit控件塞进去那么怎么实现把它塞进菜单中呢QWidgetAction *waction new QWidgetAction(0); QLineEdit* edit new QLineEdit; edit-setFixedHeight(32); edit-setPlaceholderText(请输入你的名字); edit-setClearButtonEnabled(true); waction-setDefaultWidget(edit); menu-addAction(waction);看只需要用QWidgetAction包装下就好。

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询