Two problems:
1) QPalette::Foreground is deprecated, use WindowText instead.
2) A label does not have a background in Qt4.1, only the text is drawn. To fill the background automatically you can use setAutoFillBackground(true) on your labels.
for (int i = 0; i < iColSize; i++)
{
ptrLbl->setObjectName("XXX");
ptrLbl->setAutoFillBackground( true );
ptrLbl->setGeometry( X,X,X,X );
ptrLbl
->setFrameShape
( QFrame::StyledPanel );
ptrLbl->setAlignment( int( Qt::AlignLeft ) );
ptrLbl->setMouseTracking(true);
ptrLbl->setPalette(temp);
}
QPalette temp;
temp.setColor(QPalette::WindowText, QColor(255, 0, 0));
temp.setColor(QPalette::Window, QColor(0, 0, 0));
for (int i = 0; i < iColSize; i++)
{
ptrLbl = new QLabel(this);
ptrLbl->setObjectName("XXX");
ptrLbl->setAutoFillBackground( true );
ptrLbl->setGeometry( X,X,X,X );
ptrLbl->setFrameShape( QFrame::StyledPanel );
ptrLbl->setAlignment( int( Qt::AlignLeft ) );
ptrLbl->setMouseTracking(true);
ptrLbl->setPalette(temp);
}
To copy to clipboard, switch view to plain text mode
Hope this helps.
Bookmarks