Details
-
Bug
-
Resolution: Done
-
P2: Important
-
4.6.0
-
None
-
Windows XP, Qt 4.6 build with Visual Studio 2008
-
9b0502aa6abf6bb9c07f205bccdf2d9c65027bde
Description
When a QPushButton is set to checkable and the checked attribute is used to define a background, this will not work.
If the following piece of code is executed and the button is checked then the text color will become blue, but the background will change back to grey
// Create a new button
QPushButton* button = new QPushButton("Button", this);
// Move and resize the button
button->setGeometry(50, 10, 100, 30);
// Set button checkable
button->setCheckable(true);
// Set the style sheet
// Here is the problem, when checked background should be red, but becomes grey again
// The color is blue in checked state as it should be
button->setStyleSheet(
":checked
"
":pressed
"
);
// Show the button
button->show();
How can this be resolved?