Style a QFrame with CSS depending on the frameShape in Qt 6
-
Using the Fusion style, both a
QFrame
with aHLine
andVLine
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 aQFrame
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
orborder: 1px solid red
to see it's about thepalette
value, but the setting is still not applied. Leaving out the[frameShape=...]
selector makes allQFrame
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? -
Hi,
Looks like you can reproduce that pretty easily.
I would recommend checking the bug report system to see if it's something known and if not, please open a new report providing a minimal compilable example.
-
Okay, so maybe, this is actually a bug or not implemented yet. I'll create a minimal compatible example (which is quite easy) and file a bug report.
Thanks for the feedback!
Edit: Here you are: https://bugreports.qt.io/browse/QTBUG-101877