Style a QFrame with CSS depending on the frameShape in Qt 6

260 Views Asked by At

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?

1

There are 1 best solutions below

0
On

This is actually a regression in Qt. I filed a bug report about this: https://bugreports.qt.io/browse/QTBUG-101877