Lv.的博客

PyQt5 窗口事件

################################
# PyQt5中文网 - PyQt5全套视频教程 #
#    https://www.PyQt5.cn/     #
#         主讲: 村长            #
################################

from PyQt5.Qt import *
import sys


class Window(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("窗口事件")
        self.resize(600, 500)
        self.func_list()

    # 窗口事件
    def showEvent(self, QShowEvent):
        print('窗口打开')

    def closeEvent(self,QCloseEvent):
        print('窗口关闭')

    def moveEvent(self, QMoveEvent):
        print('窗口移动')

    def resizeEvent(self, QResizeEvent):
        print('窗口缩放')

    def func_list(self):
        self.func()

    def func(self):
        pass


if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = Window()

    # window.setMouseTracking(True)

    window.show()
    sys.exit(app.exec_())

 

posted @ 2022-05-31 16:58  Avatarx  阅读(149)  评论(0编辑  收藏  举报