To control the focus rectangle of the button you have implement QWindowsStyle.
I have not tried to change the color of the focus rectangle but with the code below makes me focus rectangle of the button never appeared. Try to work with it, hope you will find a way to solve your problem.
Code:
class NewStyle : public QWindowsStyle
{
public:
void drawControl(ControlElement , const QStyleOption *,
QPainter *, const QWidget * ) const;
}
Code:
void NewStyle::drawControl(ControlElement element, const QStyleOption * option,
QPainter * painter, const QWidget * widget = 0 ) const
{
if(element == CE_PushButton)
{
const QStyleOptionButton *b = qstyleoption_cast<const QStyleOptionButton *>(option);
QStyleOptionButton *btn = (QStyleOptionButton *)b;
if (btn) {
if (btn->state & State_HasFocus) {
btn->state = btn->state ^ State_HasFocus;
}
}
QWindowsStyle::drawControl(element, btn, painter, widget);
}
else
{
QWindowsStyle::drawControl(element, option, painter, widget);
}
}
Code:
button->setStyle( new NewStyle() );
Ps: If you succeed, please share your results with everyone.
Thanks !!