QLabel *label = new QLabel("Hello, world!"); QPalette palette; palette.setColor(QPalette::Background, Qt::red); label->setAutoFillBackground(true); label->setPalette(palette);
QLabel *label = new QLabel("Hello, world!"); QPalette palette; palette.setColor(QPalette::WindowText, Qt::blue); label->setPalette(palette);This code sets the text color of the label to blue. Package library: Qt