Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to open the same window multiple times? But without close the others windows?



  • Well, I need to open this Window "QMainWindow()" multiple times, but, without close the previous windows? Anyone can help me?

    [imports]
    
    class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
        def __init__(self):
            super(MainWindow, self).__init__()
            self.setupUi(self)
            self.ButtoIniciarAnalise.clicked.connect(self.Call) #Procurar
            self.LimparSites()
    
        #
        def LimparSites(self):
            self.plainTextDados.clear()
            with open('Bin/Config/User/Root/DefaultSearch.txt', 'r') as File:
                File = File.read()
                self.plainTextDados.insertPlainText(File)
    
        def ProgressWindow(self):
            self.window = QtWidgets.QMainWindow
    
    ######### THIS WINDOW #########
        def Call(self):
            self.w = PWMainWindow()
            self.w.show()
    ################################
    
        def LimparSites1():
            plainTextDados.clear()
            with open('Bin/Config/User/Root/DefaultSearch.txt', 'r') as File:
                File = File.read()
                plainTextDados.insertPlainText(File)
    
    if __name__ == "__main__":
        app = QtWidgets.QApplication(sys.argv)
        window = MainWindow()
        window.show()
        sys.exit(app.exec_())
    


  • @Black-Cat
    Guessing what you asking...

    If you mean you want to open multiple copies of the window, you must create multiple instances:

        window1 = MainWindow()
        window1.show()
        window2 = MainWindow()
        window2.show()
    
    # or
    
        def Call(self):
            self.w1 = PWMainWindow()
            self.w1.show()
            self.w2 = PWMainWindow()
            self.w2.show()
    


  • Thanks, dude...


Log in to reply