How do I set color of text and background of a QLabel ?
You can use QPalette, however you must set setAutoFillBackground(true); to enable background color
QPalette sample_palette;
sample_palette.setColor(QPalette::Window, Qt::white);
sample_palette.setColor(QPalette::WindowText, Qt::blue);
sample_label->setAutoFillBackground(true);
sample_label->setPalette(sample_palette);
sample_label->setText("What ever text");
It works fine on Windows and Ubuntu, I haven't played with any other OS.
Note: Please see QPalette, color role section for more details