PDA

View Full Version : highlighting a QPushButton



qtUser500
8th July 2009, 17:09
- On MAC, I have a qPushButton with a background color. So essentially the whole button is of a certain color.

- When I tab to this button, I cannot see the button surrounded by a blue highlight as is normally the case when tabbing across widgets. The QPushButton is accessible from the keyboard i.e. I can press enter when I have tabbed to that button, but just can't see the highlight!

- Is there something that has to be set to push the background color into the 'background' so that the highlight can be seen?

To set the color I did the following:


myButton->setAutoFillBackground(TRUE);
QPalette myPalette = myButton->palette();
myPalette.setColor(QPalette::Button, Qt:Green);
myPalette.setColor(QPalette::Window,Qt:Green);
myButton->setPalette(myPalette);



Thanks in advance

nish
9th July 2009, 02:18
try to play with

QPalette::Light
QPalette::Midlight
QPalette::Dark
QPalette::Mid
QPalette::Shadow
QPalette::Highlight

qtUser500
10th July 2009, 15:57
Thanks for the suggestions.
Tried them but the highlight doesn't appear for the QPushButton when tabbed to.

maider
13th July 2009, 07:57
can I have a transparent button?

button1->setAutoFillBackground(true);
QPalette p( button1->palette() );
p.setBrush( QPalette::Button, Qt::transparent);
button1->setPalette( p );

I have done like this but I don't see any changes.

manishkyl
13th July 2009, 18:40
style sheets could provide cleaner solutions

QPushButton
{
background : transparent;/*background : blue;*/
border : none;
}

aamer4yu
14th July 2009, 05:29
What if you use QPalette::Window instead of QPalette::Button ?

qtUser500
14th July 2009, 20:21
I tried QPalette::Window but that doesn't change the 'highlight' behavior of the button when tabbed to. This again is a problem seen only on MAC