[Qt-interest] Set background color of a QPushButton for Windows XP
Valentina Masi
valentina.masi at altran.it
Fri Sep 17 12:24:09 CEST 2010
It works well. Thank you.
Now, I have a similar problem with QTableWidget header.
I tried to set stylesheet:
myTableWidget->horizontalHeader()->setStyleSheet("background-color: rgb(255,0,0);");
But it doesn't work in Windows XP.
How can it fix the question?
Thanks
Valentina
----- Original Message -----
From: Andre Somers
To: qt-interest at trolltech.com
Sent: Friday, September 17, 2010 11:56 AM
Subject: Re: [Qt-interest] Set background color of a QPushButton for Windows XP
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é
------------------------------------------------------------------------------
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100917/e2091dcf/attachment.html
More information about the Qt-interest-old
mailing list