How to change button style sheet?
-
I know we can change style sheet of a button like in css but I don't know how to access the style sheet
I want to use this:
But I only know this:

I just don't know how to access to the part when you can write like in css?
Please help me ! -
Hi,
If you want some sort of editable stylesheet, you should make it's content a member variable so you can then modify it to match what you want.
-
I know we can change style sheet of a button like in css but I don't know how to access the style sheet
I want to use this:
But I only know this:

I just don't know how to access to the part when you can write like in css?
Please help me !What do you mean? Variable RGB colors instead of
yellow? Where exactly is the problem?
The stylesheet can be treated as a regularQString, so you can make use ofQString::args.int value = 255; QString style("%1").args(value); -
Hi
Its very unclear what you ask about , but after some coffee I realized you may be asking how to use
same syntax as in the first screen shotFor that you can use c++ raw strings syntax
the R"()" part.This allows you to have any text directly AS IS
QString Sheet = R"( QPushButton#pushButton { background-color: yellow; } QPushButton#pushButton:pressed { background-color: rgb(224, 0, 0); } QPushButton#pushButton:hover { background-color: rgb(224, 255, 0); })"; setStyleSheet(sheet); -
Hi
Its very unclear what you ask about , but after some coffee I realized you may be asking how to use
same syntax as in the first screen shotFor that you can use c++ raw strings syntax
the R"()" part.This allows you to have any text directly AS IS
QString Sheet = R"( QPushButton#pushButton { background-color: yellow; } QPushButton#pushButton:pressed { background-color: rgb(224, 0, 0); } QPushButton#pushButton:hover { background-color: rgb(224, 255, 0); })"; setStyleSheet(sheet);@mrjj THANK YOU :))
Helped a lot!