Hi,
ich habe ein Klasse von QWidget abgeleitet und ein globales Stylesheet (Über qApp gesetzt)
Wieso kann ich über das Sheet keine background-color definieren?
Sie wird einfach irgnoriert...
DieKlasse {
background-color: red;
...}
Vielen Dank
QWidget Styling?
oder wenn dus einfacher haben willst, kannst du auch von QLabel ableiten, da kannst du dann einfach das stylesheet setzen wie du es wolltest.QWidget Supports only the background, background-clip and background-origin properties.
If you subclass from QWidget, you need to provide a paintEvent for your custom QWidget as below:
void CustomWidget::paintEvent(QPaintEvent *)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
The above code is a no-operation if there is no stylesheet set.
Warning: Make sure you define the Q_OBJECT macro for your custom widget.