How do I change the foreground or background colour

From qtnode

Jump to: navigation, search

Here's the snippet from JP online on chat.. So valuable .. ;-)

myWidget->setAutoFillBackground(true); // child widgets are transparent by default since Qt 4.1
 
QPalette p = myWidget->palette();
 
// set the background colour
p.setColor(QPalette::Window, QColor(user.color));
 
// The test colour
p.setColor(QPalette::WindowText, Qt::white);
 
myWidget->setPalette(p);
Personal tools