Reputation: 3251
I can successfully change the color of a QPushButton
using setStyleSheet
, but because I'm using Qt Creator to make the GUI, every time I run qmake
and make, the calls to setStyleSheet
disappear.
Changing the palette of the button doesn't change its color either.
What's the best way to change to color of the button without having to manually change my ui_window.h
file every time I qmake?
Upvotes: 1
Views: 8916
Reputation: 27027
Using style sheets is the right way to do, no matter you're using Qt Creator or not.
From what you are describing, it seems you are writing yourself some code into the ui_window.h
, which is the wrong way to set the stylesheet.
You can set it in the constructor of your window
class, or set it from the GUI editor (Qt Designer) :
window.ui
in the project tree displayed by Qt Creator.QPushButton
in the GUI editor.styleSheet
property in the properties editor....
) : this will bring a stylesheet editor.If you set the stylesheet with the stylesheet editor, nothing will disappear each time you are rebuilding your app.
Upvotes: 8