pyqt pyside QPushButton 图标(icon)大小自适应设置
img = QtGui.QImage(r‘d:/test.png‘)
pixmap = QtGui.QPixmap(img)
fitPixmap = pixmap.scaled(64, 64, QtCore.Qt.IgnoreAspectRatio, QtCore.Qt.SmoothTransformation) #注意 scaled() 返回一个 QtGui.QPixmap
icon = QtGui.QIcon(fitPixmap)
btn = QtWidgets.QPushButton()
btn.setIcon(fitPixmap)
btn.setIconSize(64, 64)
原文地址:https://www.cnblogs.com/ibingshan/p/10308788.html
时间: 2024-10-21 14:05:28