开发者

QWidget per-pixel translusency

开发者 https://www.devze.com 2023-04-13 07:47 出处:网络
I\'m looking at making a QWidget partially transluscent. QWidget::setMask can set a per-pixel transparency, like this, but it\'s either-or: not transluscent.

I'm looking at making a QWidget partially transluscent.

QWidget::setMask can set a per-pixel transparency, like this, but it's either-or: not transluscent.

QWidget::opacity can set a global transluscency, but it's not per-pixel.

How can I get the best开发者_如何学Python of both worlds and add a per-pixel alpha channel to the whole widget? (Decorations don't matter.)


Maybe QWidget::setMaks()?

QLabel topLevelLabel;
QPixmap pixmap(":/images/tux.png");
topLevelLabel.setPixmap(pixmap);
topLevelLabel.setMask(pixmap.mask());


It looks like the QStyle class is what you might be looking for, esp. QStyle::drawItemPixmap; then use QWidget::setStyle(). Never used this myself though.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号