i wrote a simple class that derives QPushButton, and tried to apply stylesheet on it.
but it didn’t work.
I read the qt doc, but i could not find the point.
Can any one help me out?
class Button : public QPushButton
{
Q_OBJECT
public:
Button(QWidget * parent = NULL);
~Button();
protected:
void keyPressEvent(QKeyEvent * event);
};
Button * btn = new Button(rootframe);
// I tried the following ways, all NG.
btn->setStyleSheet("background: white; color: blue;");
btn->setStyleSheet("QPushButton{background: white; color: blue;}");
btn->setStyleSheet("Button {background: white; color: blue;}");
Thanks..
From the
QtStyle Sheets Reference:This should work
It is advisable to check the
QPushButtonstylesheets example.