Hi Everybody,
I try to change the opacity in QLabel.
Using the paintEvent with this kind of code:
{
// if pixmap
if (! pixmap()->isNull())
p.drawPixmap(pixmap()->rect(), * pixmap());
p.setOpacity(0.5);
// if Text
if (! text().isEmpty())
p.drawText(rect(), text());
}
void myLabel::paintEvent(QPaintEvent * e)
{
QPainter p(this);
// if pixmap
if (! pixmap()->isNull())
p.drawPixmap(pixmap()->rect(), * pixmap());
p.setOpacity(0.5);
// if Text
if (! text().isEmpty())
p.drawText(rect(), text());
}
To copy to clipboard, switch view to plain text mode
The aim is just to change the opacity level ; The problem with this code is that , I have to redraw everything manually : style , pixmap position, text position...
it's not so easy...
If someone has something more easy, it will be fine
Thanks to all
David
Bookmarks