For a transparent pixmap, apply the opacity to the pixmap:
result.fill(Qt::transparent);
painter.setOpacity(0.5);
painter.begin(&result);
painter.drawPixmap(0, 0, original);
painter.end();
label->setPixmap(result);
QPixmap original = ...;
QPixmap result(original.size());
result.fill(Qt::transparent);
QPainter painter;
painter.setOpacity(0.5);
painter.begin(&result);
painter.drawPixmap(0, 0, original);
painter.end();
label->setPixmap(result);
To copy to clipboard, switch view to plain text mode
For transparent text, adjust palette:
color.setAlpha(127);
palette.
setColor(QPalette::Text, color
);
label->setPalette(palette);
QPalette palette = label->palette();
QColor color = palette.color(QPalette::Text);
color.setAlpha(127);
palette.setColor(QPalette::Text, color);
label->setPalette(palette);
To copy to clipboard, switch view to plain text mode
or use style sheets:
QLabel { color
: rgba
(0,
0,
0,
50%) }
QLabel { color: rgba(0, 0, 0, 50%) }
To copy to clipboard, switch view to plain text mode
No reimplementing of paintEvent() needed.
Bookmarks