我在QLabel上有一个QPixmap,QLabel是黄色的,问题是 我只是想改变QPixmap颜色的不透明度,有没有办法解决这个问题。在
from PyQt5.QtWidgets import QApplication, QLabel
from PyQt5.QtGui import QPixmap
from PyQt5.QtCore import Qt
import sys
class Pixmap(QPixmap):
def __init__(self):
super().__init__(700, 400)
self.fill(Qt.yellow)
class Drawing(QLabel):
def __init__(self):
super().__init__()
pix = Pixmap()
self.setPixmap(pix)
if __name__ == "__main__":
app = QApplication(sys.argv)
draw = Drawing()
draw.show()
sys.exit(app.exec_())
您必须创建一个新的QPixmap,并使用原始的QPixmap绘制它,QPainter设置不透明度:
相关问题 更多 >
编程相关推荐