根据 Qt 6 中的frameShape使用CSS设置QFrame的样式
使用 Fusion 样式,带有 HLine
和 VLine
frameShape
集的 QFrame
都显示为 1px 黑线。直到 Qt 5.15,外观都可以通过样式表进行更改。例如,这使得 QFrame
成为一条灰线:
QApplication application(argc, argv);
application.setStyleSheet(QStringLiteral(
// This prevents HLine and VLine QFrames to be a black line
"QFrame[frameShape=\"4\"],"
"QFrame[frameShape=\"5\"] { "
"color: palette(Mid); "
"}"));
使用 Qt 6,此设置似乎被忽略。我还尝试使用一些文字颜色,例如 color: red
或 border: 1px Solid red
来查看它与 palette
值有关,但是设置仍然没有应用。省略 [frameShape=...]
选择器会使所有 QFrame
的样式类似于相应的设置,因此显然,这是关于 [frameShape=. ..]
选择器。
我尝试使用例如frameShape=\"0x0004\"
以及例如frameShape=\"QFrame::HLine\"
。这也行不通。
根据文档,QFrame::Shape
枚举保持不变。这是否尚未实现(我用 Qt 6.2.3 尝试过),或者是否必须在 Qt 6 中以另一种方式访问它?
Using the Fusion style, both a QFrame
with a HLine
and VLine
frameShape
set are displayed as a 1px black line. Up to Qt 5.15, the appearance could be changed with style sheets. E.g. this made such a QFrame
a gray line:
QApplication application(argc, argv);
application.setStyleSheet(QStringLiteral(
// This prevents HLine and VLine QFrames to be a black line
"QFrame[frameShape=\"4\"],"
"QFrame[frameShape=\"5\"] { "
"color: palette(Mid); "
"}"));
Using Qt 6, this setting seems to be ignored. I also tried to use some literal color like color: red
or border: 1px solid red
to see it's about the palette
value, but the setting is still not applied. Leaving out the [frameShape=...]
selector makes all QFrame
s being styled like the respective setting, so apparently, this is about the [frameShape=...]
selector.
I tried to use e.g. frameShape=\"0x0004\"
and also e.g. frameShape=\"QFrame::HLine\"
. This also didn't work.
According to the docs, the QFrame::Shape
enum remains unchanged. Is this not implemented yet (I tried it with Qt 6.2.3), or does one have to access this in another way in Qt 6?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这实际上是Qt中的回归。我提交了关于此的错误报告: https://bugreports.qt.io/browse/QTBUG- 101877
This is actually a regression in Qt. I filed a bug report about this: https://bugreports.qt.io/browse/QTBUG-101877