K
K
Kir Mozor2022-03-08 19:13:22
PyQt
Kir Mozor, 2022-03-08 19:13:22

Hiding a window and opening another in PyQt, how to do?

There is a problem:

class MainWindow(QtWidgets.QMainWindow):
    def __init__(self):
        super().__init__()
        uic.loadUi("Ui/Main.ui")

class Authorize(QtWidgets.QMainWindow):
    def __init__(self):
        super().__init__()
        uic.loadUi('Ui/Authorize.ui', self)

        self.regButton.clicked.connect(self.closeWindows)
        self.dialog = MainWindow()
    def closeWindows(self):
        self.hide()
        self.dialog.setWindowTitle("Спрятали предыдущее")
        self.dialog.resize(300, 70)
        self.dialog.show()
        
def main():
    app = QtWidgets.QApplication(sys.argv)  # Новый экземпляр QApplication
    mainWindow = MainWindow()  # Создаём объект класса MainWindow
    mainWindow.show()  # Показываем окно
    app.exec_()  # и запускаем приложение

if __name__ == '__main__':  # Если мы запускаем файл напрямую, а не импортируем
    main()  # то запускаем функцию main()

I want to make it so that when a certain button is clicked, the Authorize window is hidden, and the MainWindow window is opened
. The Authorize window is hidden, but the MainWindow is not loaded.
What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question