Solved Application-Wide Stylesheet not applied on widget
-
Sounds like a problem with missing/incorrect implementation of the
paintEvent
. Can you show it?Btw. Calling
show()
from a constructor is bad manners. What if someone just wants an instance of your class without showing it (e.g. to put it in a stack or a tab)? Don't decide for them. -
@jensen82 said in Application-Wide Stylesheet not applied on widget:
No, the MACRO is there. If i've had forgotten the MACRO the setStyleSheet in the constructor wouldn't work.
no, since you're not using a class name in this style declaration...
Show the definition in the QSS file before the one that isn't working. Maybe you've a parsing error in it.
-
@Chris-Kawa Yes, i know. The show was for testing purposes.
-
@raven-worx The parsing-test was successful. No parsing error present.
Here's the Headerfile for TopNavigationLine:
class TopNavigationLine : public AUTBaseWidget { Q_OBJECT public: explicit TopNavigationLine(QWidget* parent = 0); ~TopNavigationLine(); private: Ui::TopNavigationLine* ui; };
-
@jensen82
you should please provide what you were asked for in order to receive proper help. -
@Chris-Kawa So here's the paintEvent
void AUTBaseWidget::paintEvent(QPaintEvent* event) { Q_UNUSED(event); QStyleOption opt; opt.init(this); QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); }
This code works for other derived widgets
-
@jensen82 said in Application-Wide Stylesheet not applied on widget:
The parsing-test was successful. No parsing error present.
i am wondering how you exactly checked for an error?
A normal CSS parser isn't appropriate here btw. -
Isn't there a superfluous semi-colon in setStyleSheet("background-color: rgb(77 , 77, 77);"); ?
-
@Ian-Bray No. I think i got the error. I saved the file in UTF-8 and now it works. Strange...
-
Thank you all for your help!