Qt去除图像的背景色?

weixin_38048154 2019-09-19 01:52:14
现在有几个png的图案,不过他的背景色是红色,我想利用QPixmap里面的遮罩去除掉背景色,       不过试了一下完全没作用,请问有人熟Qt图型处理的类吗?      原码:         QLabel label;         QPixmap.pixmap(xxx.png);          pixmap.createMaskFromColor(QColor(255,0,0),Qt::MaskOutColor);          label->setPixmap(pixmap);         是我的用法错误吗?拜托了举个例子让我学习
...全文
719 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38066913 2019-09-19
  • 打赏
  • 举报
回复
QPixmap pixmap("c:/6.JPG");    QBitmap bmp=pixmap.createMaskFromColor(QColor(0,0,0));    pixmap.setMask(bmp);    QLabel *label=new QLabel(this);    label->setGeometry(100,100,100,100);    label->setScaledContents(true);    label->setPixmap(pixmap);
weixin_38081808 2019-09-19
  • 打赏
  • 举报
回复
所以可能你少了setMask这一步吧!
weixin_38087753 2019-09-19
  • 打赏
  • 举报
回复
QWidget::setAttribute(Qt::WA_TranslucentBackground);Indicates that the widget should have a translucent background, i.e., any non-opaque regions of the widgets will be translucent because the widget will have an alpha channel. Setting this flag causes WA_NoSystemBackground to be set. On Windows the widget also needs the Qt::FramelessWindowHint window flag to be set. This flag is set or cleared by the widget's author.

473

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧