我在 QLabel 上有一个 QPixmap,并且 QLabel 具有黄色,问题是我只是想更改 QPixmap 颜色的 opactiy,有什么方法可以解决这个问题。
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_())
Run Code Online (Sandbox Code Playgroud)