Custom PushButton
-
Hi
How can I stop the appearance of a QPushButton changing when it is hovered over or pressed.
I know how to change the background colour for these events by setting the appropriate stylesheet, but cannot see how I can stop them changing at all.
I would appreciate some help in getting this workingThanks
-
[quote author="GrahamL" date="1385052636"]
I know how to change the background colour for these events by setting the appropriate stylesheet, but cannot see how I can stop them changing at all.[/quote]
You mean that a hovered button looks exactly the same like a non-hovered button?
If thats the case you can do this:
@
void MyPushButton::paintEvent(QPaintEvent *)
{
QStylePainter p(this);
QStyleOptionButton option;
initStyleOption(&option);
option.state &= ~QStyle::State_MouseOver; //remove hover flag in all cases ("~" is supposed to be a tilde-sign)
p.drawControl(QStyle::CE_PushButton, option);
}
@