Button style on the form

Viewed 73

Please tell me how to correctly specify the arguments for the fact that all the buttons on the form had a style when you hover the mouse over these buttons? In addition to the style for the button, there is also a style for the form itself.

I specify it in the constructor:

{
    ui->setupUi(this);
    this->setStyleSheet("background: rgb(49, 54, 59); color: rgb(220, 221, 218); selection-color: lightyellow; selection-background-color: darkcyan;"
                                         "QPushButton::hover {color: darkcyan; border: 2px solid grey; border-radius: 1px};");

}

It works if I only specify a separate style for the button, but I need to combine all the styles into one entry.

this->setStyleSheet("QPushButton::hover {color: darkcyan; border: 2px solid grey; border-radius: 1px};");
1 Answers

I think you are looking for this

this->setStyleSheet("QWidget { background: rgb(49, 54, 59); color: rgb(220, 221, 218); selection-color: lightyellow; selection-background-color: darkcyan; }"
                        " QPushButton::hover {color: darkcyan; border: 2px solid grey; border-radius: 1px};");

If your main form is QMainWindow you can also set style only for QMainWindow but not for all QWidgets

this->setStyleSheet("QMainWindow { background: rgb(49, 54, 59); color: rgb(220, 221, 218); selection-color: lightyellow; selection-background-color: darkcyan; }"
                   " QPushButton::hover {color: darkcyan; border: 2px solid grey; border-radius: 1px};");
Related