PDA

View Full Version : Modifying custom style, derived from QPlastiqueStyle to prevent rollover highlighting



sternocera
31st March 2009, 15:59
Hello,

I am developing a Qt for embedded Linux application to be used with a touchscreen. I'm using a custom style, derived from QPlastiqueStyle but with "chunky" scrollbars to ease use with a touchscreen.

It is inappropriate how QPlastiqueStyle has a rollover effect, given that this application will only ever be used with a touchscreen.

Is there a way to prevent the rollover highlight effect from appearing?

Thanks,
Sternocera

talk2amulya
31st March 2009, 17:33
which element's rollover event are you talking about..whichever element it is..u can disable it by using "hover" property in stylesheets.

sternocera
1st April 2009, 10:26
I am referring to QPushButton's "hover" events....when they take on blue highlights while the mouse cursor is rolled over. That's all I want to change.

I'm already using a custom style. Can I further extend it to suppress this hover behaviour?

Regards,
Sternocera

talk2amulya
1st April 2009, 11:14
try:


urPushButton->setAttribute(Qt::WA_Hover, false);

sternocera
1st April 2009, 11:47
talk2amulya,

Hmm....I appreciate the suggestion, but that will create a lot of boiler plate that will have to be maintained for dozens of QPushButtons. I was hoping to achieve the same end by modifying my application's custom, QPlastiqueStyle derived style.

I realised that I could do what you've suggested for all widgets in my style:


void QMyStyle::polish(QWidget* widget) // re-implement virtual function from QStyle
{
widget->setAttribute(Qt::WA_Hover, false);
}

This works; the rollover effect disappears. However, I now have another problem: When I actually press a button, the blue highlighting "sticks" to it until it is re-drawn.

I have no idea why this might be. Do you?

Regards,
Sternocera

talk2amulya
1st April 2009, 12:16
maybe you have done certain stuff with QStyle::State_Sunken, if not, u can work on drawPrimitive() for your button and resolve the issue