how to return a variable from another window in pyqt?

风格不统一 提交于 2021-02-17 06:52:07

问题


I have one main window and one dialog in PYQT. I receive the input from user in main window and then open the dialog window and pass the input to this window.

in dialog window again I receive another input and add this new input with the other input which I passed form main window.

class MainWindow (QMainWindow):
    def __init__(self):
        super().__init__()
        self.window=Ui_MainWindow() 
        self.window.setupUi(self)   

     def open_qdialog_window(self):
        
        self.dialog_window = Qdialog(self.window.lineedit1.currentText())

        self.dialog_window .show()

class Qdialog(QDialog):
    def __init__(self,DS_parameter):
        super().__init__()
        
        self.DS_parameters=DS_parameters
        #UI file of oscilloscope
    
        self.window=Ui_Qdialog()
        self.window.setupUi(self)
        self.UI()
    
    def summation(self):
        self.DS_parameters=self.DS_parameters+self.window.lineedit2.currentText()

Now the question is how I can return self.DS_parameters to the main window and update editline1 with this new value?

来源:https://stackoverflow.com/questions/64343633/how-to-return-a-variable-from-another-window-in-pyqt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!