Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, August 2007
Changing background color of a button on Windows Xp


Message 1 in thread

Hi,
 
I am not able to change the background color of a QPushButton on windows
XP.
 
I do the following :-
 
QPushButton *tb = new QPushButton(ww);
QColor col((Qt::GlobalColor)(i + Qt::black));
tb->setFixedSize(s, s);
QPalette p;
p.setColor(QPalette::Button, QColor(255,0,0));
tb->setPalette(p);
 
Am I doing anything wrong here ?
Please suggest.
 
Thnx
Prateek

Message 2 in thread

Prateek Tiwari wrote:
> I am not able to change the background color of a QPushButton on
windows
> XP.
> 
> I do the following :-
> 
> QPushButton *tb = new QPushButton(ww);
> QColor col((Qt::GlobalColor)(i + Qt::black));
> tb->setFixedSize(s, s);
> QPalette p;
> p.setColor(QPalette::Button, QColor(255,0,0));
> tb->setPalette(p);
> 
> Am I doing anything wrong here ?
> Please suggest.
> 
> Thnx
> Prateek

The XP Style has background pixmaps for buttons, you'll need to disable
those (by setting your own style or style sheet) in order to see the
background.

Cheers,
Peter

--
 [ signature omitted ]