Put an Image on a QPushButton
问题 I'm a beginner in PyQt and I have an image known as add.gif . I need to put this image in a QPushButton but I don't know how. 回答1: Example: from PyQt4 import QtGui, QtCore class Window(QtGui.QWidget): def __init__(self): QtGui.QWidget.__init__(self) self.button = QtGui.QPushButton('', self) self.button.clicked.connect(self.handleButton) self.button.setIcon(QtGui.QIcon('myImage.jpg')) self.button.setIconSize(QtCore.QSize(24,24)) layout = QtGui.QVBoxLayout(self) layout.addWidget(self.button)