N
N
Nikita Yaremenko2020-05-14 07:53:57
Python
Nikita Yaremenko, 2020-05-14 07:53:57

How to implement correct transition between Dialog and MainWindow PyQt5?

In general, the code is below. process in the dispatcher, who will tell you how to implement the transition in a more humane way?
(code to understand how it works..)

class Win2(QtWidgets.QDialog):
    
    def __init__(self, parent = None):
        super(BkTo, self).__init__(parent)
        self.bk = Ui_BackTo()
        self.bk.setupUi(self)
 
 
 
class Win1(QtWidgets.QMainWindow):
    def __init__(self, parent=None):
        QtWidgets.QWidget.__init__(self, parent)
 
        self.ui = Ui_MainWindow()
 
        self.ui.setupUi(self)
 
        self.ui.Enter.clicked.connect(self.enterOpen) 
 
    def enterOpen(self):
            dial = Win2(self)
            dial.exec_()
            dial.show()     
 
if __name__ == "__main__":       
    app = QtWidgets.QApplication([])
    application = MyWin()
 
    application.show()
    sys.exit(app.exec())

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MechanicZelenyy, 2020-05-26
@MechanicZelenyy

class Win2(QtWidgets.QDialog):
    
    def __init__(self, parent = None):
        super(BkTo, self).__init__(parent)

I think it is necessary to determine from whom exactly you are inherited --- it is desirable to pass one of the parents to super.
dial.exec_()
            dial.show()

This is a tautology, you only need exec.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question