highlighting a QPushButton
- 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:
Code:
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
Re: highlighting a QPushButton
try to play with
QPalette::Light
QPalette::Midlight
QPalette::Dark
QPalette::Mid
QPalette::Shadow
QPalette::Highlight
Re: highlighting a QPushButton
Thanks for the suggestions.
Tried them but the highlight doesn't appear for the QPushButton when tabbed to.
Re: highlighting a QPushButton
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.
Re: highlighting a QPushButton
style sheets could provide cleaner solutions
QPushButton
{
background : transparent;/*background : blue;*/
border : none;
}
Re: highlighting a QPushButton
What if you use QPalette::Window instead of QPalette::Button ?
Re: highlighting a QPushButton
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