How to set QToolBar color without losing the blue QToolButton hover effect
-
Everytime I try to set the background color of my toolbar I lose the blue hover effect of the Actions/ToolButtons.
I tried with setting a new stylesheet and also with appending to the existing one.When using one of the following, I lose the hover effect:
ui->toolBar->setStyleSheet("background-color: rgba(200, 200, 200, 255);"); //or ui->toolBar->setStyleSheet(ui->toolBar->styleSheet().append("background-color: rgba(200, 200, 200, 255);"));
When adding the hover part, I use the background color of the Toolbar instead.
ui->toolBar->setStyleSheet("background-color: rgba(200, 200, 200, 255); QToolButton:hover {background-color: blue};"); //or ui->toolBar->setStyleSheet(ui->toolBar->styleSheet().append("background-color: rgba(200, 200, 200, 255); QToolButton:hover {background-color: blue};"));
I tried playing with Palette in Designer but that did not work at all.
What is the right way of doing this?
-
@Megamouse said in How to set QToolBar color without losing the blue QToolButton hover effect:
ui->toolBar->setStyleSheet("background-color: rgba(200, 200, 200, 255);");
Use
ui->toolBar->setStyleSheet("QToolBar { background-color: rgba(200, 200, 200, 255); }");
maybe that helps.
-
@Megamouse
Super :)
And to the typename, you can also add instance name (object name)
QPushButton#evilButton { background-color: red }
Type QPushButton but only named evilButton
http://doc.qt.io/qt-5/stylesheet-examples.htmlYou can apply stylesheet to QApplication.
That is the highest parent you can get and it will affect most.