customcommand: add stylesheet to structured output#2350
Conversation
| } else if (name_value[0] == "icon") { | ||
| iconsetter(value, true); | ||
| } else if (name_value[0] == "stylesheet") { | ||
| mButton->setStyleSheet(QString::fromUtf8(value)); |
There was a problem hiding this comment.
I'm just wondering. Can the input be somehow validated? @tsujan do you know of any method for qss validation?
There was a problem hiding this comment.
@tsujan do you know of any method for qss validation?
No, have never done it.
But it's up to the user to provide a valid stylesheet; isn't it? Unless a bad situation (like hang or crash) happens with an invalid one.
Unrelated: IMHO, it's also good to check CPU/memory usage with such usages.
There was a problem hiding this comment.
I found this https://github.com/KDABLabs/qsslint/blob/master/main.cpp
Apparently uses #include <QtGui/private/qcssparser_p.h> but i think this was made for Qt5
There was a problem hiding this comment.
#include <QtGui/private/qcssparser_p.h>
...
const QString qss = QString::fromUtf8(value);
QCss::Parser parser(qss);
QCss::StyleSheet ss;
if (parser.parse(&ss)){
mButton->setStyleSheet(qss);
}that seems to work, but it requires
target_link_libraries(mytarget PRIVATE Qt6::GuiPrivate) from this https://doc.qt.io/qt-6/qtguiprivate-module.html
i don't know where to add it so i put it in BuildPlugin.cmake to test it, but that doesn't seem like a good idea, i think.
https://github.com/qt/qtbase/blob/dev/src/gui/text/qcssparser.cpp link to source i'm using to try to understand how to use it.
There was a problem hiding this comment.
I really doubt that we need to verify that a stylesheet is valid. It's Qt's job to do so, as that's the case anywhere a stylesheet is used (e.g., LXQt themes).
There was a problem hiding this comment.
yeah it's probably fine to not check it,
added stylesheet to structured output and changed handling of
textColorso it doesn't conflict with it.whatsthis text:

test script with Continuous output checked and Structured selected in Output format:
stylesheet-2025-10-10_07.25.23.mp4