In my main() function I'm setting styleSheet on all buttons of my application.
qApp->setStyleSheet("QPushButton {"
" border: 1px solid #8f8f91;"
" border-radius: 4px;"
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f6f7fa, stop: 1 #dadbde);"
" padding: 3px;"
" }");
But now I need to reset the style of some buttons. I've tried button->setStyleSheet("")
, but it is not working. So, how to do that?
You can't.
What you can do is the opposite, i.e. setting the stylesheet for certain buttons like this:
qApp->setStyleSheet("QPushButton[specialButton=\"true\"] {"
" border: 1px solid #8f8f91;"
" border-radius: 4px;"
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f6f7fa, stop: 1 #dadbde);"
" padding: 3px;"
"}");
and then:
button->setProperty("specialButton", true);
This way only the buttons with specialButton set to true
will have the custom look, the others will look normal.