PDA

View Full Version : QT push button style sheet issue



meraj ansari
13th May 2010, 10:54
Hi,

I have a push button and i want to set its style for normal, hover and pressed state. The style sheet code i used is-

QPushButton#myButton {
background-image: url(:/image/normal.bmp);
border: none;
}

QPushButton#myButton:pressed {
background-image: url(:/image/pressed.bmp);
border: none;
}

QPushButton#myButton:hover{
background-image: url(:/image/hover.bmp);
border: none;
}

with this style sheet, normal and hover images are displayed but when i pressed button then button is not showing image for pressed state. Image for hover state is not changed in the pressed state image.

Any suggestion what i am doing wrong?

Lykurg
13th May 2010, 11:13
You have to change the order of pressed and hover. Then it works.

meraj ansari
13th May 2010, 11:30
Thanks Lykurg

harvey_slash
3rd October 2013, 15:39
it doesn't work for me .
I used this

QPushButton#pushButton {
background-color: red;
border-style: outset;
border-width: 2px;
border-radius: 10px;
border-color: beige;
font: bold 14px;
min-width: 10em;
padding: 6px;
}
QPushButton#pushButton:pressed {
background-color: rgb(224, 0, 0);
border-style: inset;
}


QPushButton#pushButton:hover {
background-color: rgb(224, 255, 0);
border-style: inset;
}

Lykurg
4th October 2013, 13:56
Well, aslo you have to change the order...
QPushButton#pushButton:hover {
background-color: rgb(224, 255, 0);
border-style: inset;
}

QPushButton#pushButton:pressed {
background-color: rgb(224, 0, 0);
border-style: inset;
}