Qt 样式表错误?

编程入门 行业动态 更新时间:2024-10-12 05:51:40
本文介绍了Qt 样式表错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在简单的 QSS(Qt 样式表)中有很多错误.是Qt的bug吗?

I have a many bugs at simple QSS(Qt style sheets). Is it bugs of Qt?

示例:

样式表:

#check1 { color: red //didn't work here } #check2 { color: red; //but work here background-color: black } #label1 { color: blue; text-decoration: underline //work fine here } #label2:hover { color: blue; text-decoration: underline //but didn't work here }

来源:

#include <QtGui> int main(int argc, char *argv[]) { QApplication app(argc, argv); app.setStyleSheet(" #check1 {color: red} \ #check2 {color: red; background-color: black} \ #label1 {color: blue; text-decoration: underline} \ #label2:hover {color: blue; text-decoration: underline}"); QWidget w; w.setFixedSize(120,130); QCheckBox check1("checkbox1",&w); check1.setObjectName("check1"); check1.move(10,0); QCheckBox check2("checkbox1",&w); check2.setObjectName("check2"); check2.move(10,30); QLabel label1("label1", &w); label1.setObjectName("label1"); label1.move(10,60); QLabel label2("label2", &w); label2.setObjectName("label2"); label2.move(10,90); w.show(); return app.exec(); }

qt 4.7.3-3;拱形Linux;gnome 3 后备模式

qt 4.7.3-3; arch linux; gnome 3 fallback mode

推荐答案

对于第一个复选框,问题出在 Gtk+ 风格的某处:

For the first checkbox, the problem is somewhere in the Gtk+ style:

QLabel、QPushButton 或 QCheckBox 不支持字体更改(包括 text-decoration):hover 伪状态 css 选择器.最简单的小部件似乎是 QToolButton (如果你真的需要,它可以用来替换 QLabels).所有小部件都支持该状态的调色板更改(前景色和背景色以及样式).

QLabel, QPushButton or QCheckBox don't support font changes (including text-decoration) in the :hover pseudo-state css selector. The simplest widget that does seems to be QToolButton (which could be used to replace the QLabels if you really need that). Palette changes (foreground and background colors and styles) for that state are supported by all the widgets.

更多推荐

Qt 样式表错误?

本文发布于:2023-07-09 21:20:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1088242.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:样式表   错误   Qt

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!