我是PyQt5的新手,关于如何在已加载的图像(QPixmap("myPic.png")上使用QPainter绘制,我找不到适合我的答案。我尝试在paintEvent方法中进行操作,但没有成功。如果我想在下面的代码片段中在已加载的图像上绘制一条线,应该怎么做?
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
class Example(QWidget):
def __init__(self):
super().__init__()
self.setGeometry(30, 30, 500, 300)
self.initUI()
def initUI(self):
self.pixmap = QPixmap("myPic.png")
lbl = QLabel(self)
lbl.setPixmap(self.pixmap)
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())