我需要在标签中显示图片和文本,这是我的代码:import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
class MyLabel(QLabel):
def __init__(self):
super(MyLabel, self).__init__()
def paintEvent(self, QPaintEvent):
pos = QPoint(50, 50)
painter = QPainter(self)
painter.drawText(pos, 'hello,world')
painter.setPen(QColor(255, 255, 255))
class Window(QWidget):
def __init__(self):
super(Window, self).__init__()
layout = QHBoxLayout(self)
self.label = MyLabel()
self.pixmap = QPixmap('icon.png')
self.label.setPixmap(self.pixmap)
layout.addWidget(self.label)
if __name__ == '__main__':
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_(