1.在qt designer中设计两个简单窗口
2.将.ui文件转换成.py文件
3.新建**.py文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#-*- coding:utf-8 -*- from pyqt5.qtwidgets import qmainwindow, qapplication from window import ui_mainwindow from child import ui_child import sys class main(qmainwindow,ui_mainwindow): def __init__( self ): super (main, self ).__init__() self .setupui( self ) class child(qmainwindow,ui_child): def __init__( self ): super (child, self ).__init__() self .setupui( self ) self .pushbutton.clicked.connect( self .close) def open ( self ): self .show() if __name__ = = "__main__" : app = qapplication(sys.argv) main = main() ch = child() main.show() main.pushbutton.clicked.connect(ch. open ) sys.exit(app.exec_()) |
以上这篇pyqt5实现从主窗口打开子窗口的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/Hubz131/article/details/79353818