根据 Qt 6 中的frameShape使用CSS设置QFrame的样式

发布于 2025-01-14 21:35:18 字数 921 浏览 2 评论 0原文

使用 Fusion 样式,带有 HLineVLine 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: redborder: 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 QFrames 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别再吹冷风 2025-01-21 21:35:18

这实际上是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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文