moijhd
2nd April 2013, 17:11
Hi,
I have a MyWidget object which inherits from QWidget.
The following function is supposed to change the background color of a MyWidget object but it does not work.
Any remarks ?
Thanks.
// Set a color
void MyWidget::setColor(const QColor &color)
{
// Prepare the style
QString style = "background-color: rgb(%1, %2, %3);";
// Set the color
this->setStyleSheet(
style
.arg(color.red())
.arg(color.green())
.arg(color.blue())
);
qDebug() << this->styleSheet();
}
PS : the debug instruction returns the correct style sheet.
I have a MyWidget object which inherits from QWidget.
The following function is supposed to change the background color of a MyWidget object but it does not work.
Any remarks ?
Thanks.
// Set a color
void MyWidget::setColor(const QColor &color)
{
// Prepare the style
QString style = "background-color: rgb(%1, %2, %3);";
// Set the color
this->setStyleSheet(
style
.arg(color.red())
.arg(color.green())
.arg(color.blue())
);
qDebug() << this->styleSheet();
}
PS : the debug instruction returns the correct style sheet.