Answer the question
In order to leave comments, you need to log in
How to create a child window in pyqt5?
I created 2 simple windows in Qt Designer:
Next, I decided to try by pressing the "Deposit account" button, close the main window and open 2:
But when I create 2 windows, I have nothing in it and it does not match its size
Here is the code that I wrote :
import sys
import first_window
import double_window
from PyQt5 import QtCore, QtGui, QtWidgets
class TwoWindow(QtWidgets.QMainWindow, double_window.Ui_MainWindow):
def __inir__(self):
super().__init__()
self.setupUi(self)
#self.pushButton.clicked.connect(self.check2)
class OneWindow(QtWidgets.QMainWindow, first_window.Ui_MainWindow):
def __init__(self, parent = None):
super().__init__(parent)
self.setupUi(self)
self.twoWindow = None
self.pushButton.clicked.connect(self.check)
def check(self):
#print (5)
self.close()
self.twoWindow = TwoWindow()
self.twoWindow.show()
def main():
app = QtWidgets.QApplication(sys.argv)
window = OneWindow()
window.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question