PDA

View Full Version : Background of checked QPushButton with stylesheet



bouchebeu
13th May 2014, 09:17
Hello everyone,

My problem is simple: my checked (not pressed) QPushButton background color (setted with stylesheet) is not displayed as wanted; it looks like a Qt::Dense6Pattern is present.
I tried to modify the stylesheet with different selectors, but no luck for now.

Below is the simplest code.



int main(int argc, char *argv[]){
QApplication app(argc, argv);
QMainWindow win;
QPushButton b1("Button 1", &win);

b1.setCheckable(true);
b1.setChecked(true);
b1.setStyleSheet("QPushButton {background-color: blue;}");

win.show();

return app.exec();
}



Does this issue ring a bell ?

Thanks !

bouchebeu
13th May 2014, 16:47
What I had to do is modify the button's border in order to bypassing the default's style.



QPushButton:checked {
background-color: blue;
border: none; // or something else
}