PDA

View Full Version : Problem mit Stylesheets



momesana
10th November 2006, 20:30
Hi, I have a problem with stylesheets when applied to QLabels. The background-attribute is simply ignored. But when I swiftly resize the widget with the mousecurser, I can see traces of its background-color at the edge of the Window.

Thanx in advance
momesana



#include<QApplication>
#include <QtGui>

int main( int argc, char ** argv)
{
QApplication app( argc, argv);
QMainWindow * mw = new QMainWindow;
QLabel * label = new QLabel(mw);
label->setText("Where is my color??? :'(");
label->setStyleSheet( "background-color:yellow; text-align:center; color:blue;" );
mw->setCentralWidget(label);
mw->show();
return app.exec();
}

jpn
10th November 2006, 20:41
Seems you have to:


label->setAutoFillBackground(true);