To be more precise, I could use:
QWidget#idName { border: 1px solid grey; }
or
Box { border: 1px solid grey; }
The latter is simpler, in my opinion, since it does not require the use of name names.
The main problem with why they do not work is that it is considered custom widgets and therefore requires a custom drawing event:
void Box::paintEvent(QPaintEvent *) { QStyleOption opt; opt.init(this); QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); }
This was taken from: Qt style sheets for a custom widget
chacham15
source share