【发布时间】:2018-04-28 02:33:46
【问题描述】:
在 Qt 中我使用以下方法加载图像并将其设置为 QLabels 的背景:
QPixmap *pixmap= new QPixmap("home\\Images\\circle.png");
ui->cell11_Image->setPixmap(*pixmap);
ui->cell11_Image->setMask(pixmap->mask());
ui->cell11_Image->show();
delete(pixmap);
结果如下
问题是:图像是灰度的。但是,这是其中一张图片
有人知道怎么回事吗?
【问题讨论】:
-
您的表单中有样式表吗?
-
为什么需要这个电话
ui->cell11_Image->setMask(pixmap->mask());? -
@vahancho 我愿意。我有两个样式表。我删除了它们,但它并没有改变所描述的行为。关于 setMask 行:我希望只显示图像覆盖的区域。删除该行不会改变之前的行为。