[Qt-interest] Set background color of a QPushButton for Windows XP
Andre Somers
andre at familiesomers.nl
Fri Sep 17 11:56:35 CEST 2010
Op 17-9-2010 11:49, Valentina Masi schreef:
> Hi all
> In my Qt application I have to set the background color for some
> QPushButton to another color from default color.
> My app runs in Windows XP and I need to use Windows XP style (not
> classic Windows style).
> I tried as follows:
> QPalette palette = myPushButton->palette();
> QBrush brush(QColor(255, 0, 0, 255)); // red
>
> brush.setStyle(Qt::SolidPattern);
>
> palette.setBrush(QPalette::Active, QPalette::Button, brush);
>
> palette.setBrush(QPalette::Inactive, QPalette::Button, brush);
>
> palette.setBrush(QPalette::Disabled, QPalette::Button, brush);
>
> myPushButton->setPalette(palette);
>
> But it works only if I set classic Windows style.
> I also tried to use stylesheet but the problem remained.
> Can anyone help me?
>
Styles are allowed to ignore the pallette you set. But the build in
styles *will* obey style sheets. So, use a style sheet instead.
André
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100917/eed18801/attachment.html
More information about the Qt-interest-old
mailing list