PDA

View Full Version : QPalette in rgb



tommy
13th January 2008, 18:15
This is how I change the backround or my QLabel


QPalette Pal2(pixmapLabel->palette());
Pal2.setColor(QPalette::Window, Qt::gray);
pixmapLabel->setAutoFillBackground(true);
pixmapLabel->setPalette(Pal2);

I would now like to change the background color to rgb color where I replace "Qt::gray" with RGB numbers. How do I do that?
So far I've tried this.


Pal2.setColor(QPalette::Window, QColor::rgb(150,150,150));

and


Pal2.setColor(QPalette::Window, QRgb::rgb(150,150,150));

but neither work.

jacek
13th January 2008, 18:25
It should be QColor::fromRgb( r, g, b ).

wysota
15th January 2008, 10:21
Or QColor(r,g,b).