Python Pyqt5 QMainWindow 通过字节流设置背景图片
// set MainWindow BackDrop
from PyQt5 import QtWidgets ,QtGui
mw = QtWidgets.QMainWindow()
with open('image.png','rb') as f :
BACKIMAGE_DATA = f.read()
QP = QtGui.QPixmap()
QP.loadFromData(BACKIMAGE_DATA) # 传入字节流图片数据
palette = QtGui.QPalette()
palette.setBrush(QtGui.QPalette.Background, QtGui.QBrush(QP))
mw.setPalette(palette)