pyqt5设置主窗体MainWindow背景图片

Python 944 0 2020-11-25

pyqt5设置主窗体MainWindow背景图片
#基本框架
from PyQt5.QtGui import QPainter, QPixmap

#主要代码段
class QmyMainWindow(QMainWindow):
    def __init__(self,parent=None):
        super().__init__(parent)

        self.setAutoFillBackground(True)
        self.__pic=QPixmap("bg.jpg")

    def paintEvent(self,event):
        painter=QPainter(self)
        painter.drawPixmap(0,self.ui.toolBar.height(),self.width(),self.height()-self.ui.toolBar.height()-self.ui.statusbar.height(),self.__pic)
        super().paintEvent(event)

上一篇:python图形开发GUI库pyqt5的详细使用方法及各控件的属性与方法

下一篇:PyQt5内置类QtSql操作 连接mysql5.7数据库

讨论数量:0

请先登录再发表讨论。 2024-04-27

天涯网魂
3 杠 5 星
TA 的文章
TA 的随言
TA 的资源链