Why sometimes the style of a button changes
-
The upper part of this picture is the style I set, and the third button is the hover state. But sometimes after the program runs for a period of time, When I hovered the mouse over the button, it changed to look like the bottom half of the image, and their functions are normal at this time. Because the styles of these buttons will not change during program operation, I am puzzled why this is the case?

-
Hi,
How are you rendering this button ?
On which platform ?
With version of Qt ? -
ui->btn_min->setIcon(icon); ui->btn_min->setIconSize(QSize(25, 25)); ui->btn_min->setStyleSheet("QPushButton#btn_min,#btn_max { background-color: #303030; } QPushButton#btn_min:hover { background-color: #454545; }");vs2019+qt vs tools
qt 5.14.2This situation only occurs occasionally, so I'm sorry I couldn't find some pattern to provide more information.
Thanks.
-
ui->btn_min->setIcon(icon); ui->btn_min->setIconSize(QSize(25, 25)); ui->btn_min->setStyleSheet("QPushButton#btn_min,#btn_max { background-color: #303030; } QPushButton#btn_min:hover { background-color: #454545; }");vs2019+qt vs tools
qt 5.14.2This situation only occurs occasionally, so I'm sorry I couldn't find some pattern to provide more information.
Thanks.
You should test this with a more recent version of Qt.
-
ui->btn_min->setIcon(icon); ui->btn_min->setIconSize(QSize(25, 25)); ui->btn_min->setStyleSheet("QPushButton#btn_min,#btn_max { background-color: #303030; } QPushButton#btn_min:hover { background-color: #454545; }");vs2019+qt vs tools
qt 5.14.2This situation only occurs occasionally, so I'm sorry I couldn't find some pattern to provide more information.
Thanks.
@John-Van You are only setting the style sheet set on btn_min but complaining about the changed style of other icons. Perhaps you could post a self-contained, complete example that reproduces the failure.
BTW, I'd try removing the half-reference to #btn_max from the style you attached to btn_min.