jiveaxe
2nd May 2014, 11:29
Hi, I have a problem when using QGraphicsDropShadowEffect onto a QLabel.
I want to draw a shadow around a label's text. The label's content is not static but changes over time.
When I start the application all seems ok:
10332
but starting from the third change a shadow is drawn all around the label:
10334
Curiously, this does not happen when using the same string with QLabel::setText().
This is the code I'm using:
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
ui->frame->setBackgroundRole(QPalette::AlternateBase);
ui->frame->setAutoFillBackground(true);
QGraphicsDropShadowEffect *coverShadow = new QGraphicsDropShadowEffect(this);
coverShadow->setBlurRadius(10.0);
coverShadow->setColor(palette().color(QPalette::Shadow));
coverShadow->setOffset(0.0);
ui->label->setWindowFlags(Qt::FramelessWindowHint);
ui->label->setAttribute(Qt::WA_TranslucentBackground);
ui->label->setGraphicsEffect(coverShadow);
}
Any idea about the problem?
Very thanks
Quick update:
Noticed that resizing the dialog make shadow frame disappear. Unfortunately, no luck with QLabel::update(), QLabel::resize(), QLabel::adjustSize()...
I want to draw a shadow around a label's text. The label's content is not static but changes over time.
When I start the application all seems ok:
10332
but starting from the third change a shadow is drawn all around the label:
10334
Curiously, this does not happen when using the same string with QLabel::setText().
This is the code I'm using:
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
ui->frame->setBackgroundRole(QPalette::AlternateBase);
ui->frame->setAutoFillBackground(true);
QGraphicsDropShadowEffect *coverShadow = new QGraphicsDropShadowEffect(this);
coverShadow->setBlurRadius(10.0);
coverShadow->setColor(palette().color(QPalette::Shadow));
coverShadow->setOffset(0.0);
ui->label->setWindowFlags(Qt::FramelessWindowHint);
ui->label->setAttribute(Qt::WA_TranslucentBackground);
ui->label->setGraphicsEffect(coverShadow);
}
Any idea about the problem?
Very thanks
Quick update:
Noticed that resizing the dialog make shadow frame disappear. Unfortunately, no luck with QLabel::update(), QLabel::resize(), QLabel::adjustSize()...