Here you go, using QPalette
//main.cpp
#include <QtGui>
//QLabel background
class MyWidget
: public QLabel{
public:
{
setText("QLabel");
p.
setColor(QPalette::WindowText, Qt
::white);
setPalette(p);
}
};
int main(int argc, char *argv[])
{
MyWidget w;
w.show();
return a.exec();
}
#include "main.moc"
//main.cpp
#include <QtGui>
//QLabel background
class MyWidget : public QLabel
{
public:
MyWidget(QWidget* parent = 0) : QLabel(parent)
{
setText("QLabel");
QPalette p = palette();
p.setColor(QPalette::Window, Qt::blue);
p.setColor(QPalette::WindowText, Qt::white);
setPalette(p);
}
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MyWidget w;
w.show();
return a.exec();
}
#include "main.moc"
To copy to clipboard, switch view to plain text mode
Bookmarks