I am trying to add a label with color palette, to a QTableWidget. But its not displayed with the color i set to label palette. here is my code,
QWidget *colorTableWidget = new QWidget();
QLabel *lbl = new QLabel();
lbl->setAutoFillBackground(true);
QPalette palette;
palette.setColor(lbl->backgroundRole(), QColor("RED") );
lbl->setPalette(palette);
QGridLayout *gridLayout = new QGridLayout();
gridLayout ->addWidget(lbl,0,0);
colorTableWidget->setLayout(gridLayout);
ui->tableWidget->setCellWidget(row,0,colorTableWidget);
could any one tell me what is wrong here.. ?, same thing is working when I add a text to the label but its not working for color palette. I am using Qt 4.8.4 in win 7 environment.