title: How to retrieve data from dialog window to mainwindow in pyqt?
body: <pre><code># -*- coding: utf-8 -*-
  
  # Form implementation generated from reading ui file 'maintest.ui'
  #
  # Created by: PyQt4 UI code generator 4.11.4
  #
  # WARNING! All changes made in this file will be lost!
  
  from PyQt4 import QtCore, QtGui
  from test import Ui_Dialog
  
  try:
      _fromUtf8 = QtCore.QString.fromUtf8
  except AttributeError:
      def _fromUtf8(s):
          return s
  
  try:
      _encoding = QtGui.QApplication.UnicodeUTF8
      def _translate(context, text, disambig):
          return QtGui.QApplication.translate(context, text, disambig, _encoding)
  except AttributeError:
      def _translate(context, text, disambig):
          return QtGui.QApplication.translate(context, text, disambig)
  
  class Ui_MainWindow(object):
  
      def connect(self):
          self.updateWindow=QtGui.QDialog()
          self.ui_update=Ui_Dialog()
          self.ui_update.setupUi(self.updateWindow)
          self.updateWindow.show()
  
      def setupUi(self, MainWindow):
          MainWindow.setObjectName(_fromUtf8("MainWindow"))
          MainWindow.resize(391, 248)
          self.centralwidget = QtGui.QWidget(MainWindow)
          self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
          self.lineEdit = QtGui.QLineEdit(self.centralwidget)
          self.lineEdit.setGeometry(QtCore.QRect(80, 60, 113, 27))
          self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
          self.pushButton = QtGui.QPushButton(self.centralwidget)
          self.pushButton.setGeometry(QtCore.QRect(80, 100, 112, 34))
          self.pushButton.setObjectName(_fromUtf8("pushButton"))
          MainWindow.setCentralWidget(self.centralwidget)
          self.menubar = QtGui.QMenuBar(MainWindow)
          self.menubar.setGeometry(QtCore.QRect(0, 0, 391, 31))
          self.menubar.setObjectName(_fromUtf8("menubar"))
          MainWindow.setMenuBar(self.menubar)
          self.statusbar = QtGui.QStatusBar(MainWindow)
          self.statusbar.setObjectName(_fromUtf8("statusbar"))
          MainWindow.setStatusBar(self.statusbar)
  
          self.retranslateUi(MainWindow)
          QtCore.QMetaObject.connectSlotsByName(MainWindow)
  
      def retranslateUi(self, MainWindow):
          MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
          self.pushButton.setText(_translate("MainWindow", "B1", None))
          self.pushButton.clicked.connect(self.connect)
  
  if __name__ == "__main__":
      import sys
      app = QtGui.QApplication(sys.argv)
      MainWindow = QtGui.QMainWindow()
      ui = Ui_MainWindow()
      ui.setupUi(MainWindow)
      MainWindow.show()
      sys.exit(app.exec_())
  </code></pre>
  
  <p>this was the main file code</p>
  
  <pre><code># -*- coding: utf-8 -*-
  
  # Form implementation generated from reading ui file 'test.ui'
  #
  # Created by: PyQt4 UI code generator 4.11.4
  #
  # WARNING! All changes made in this file will be lost!
  
  from PyQt4 import QtCore, QtGui
  
  try:
      _fromUtf8 = QtCore.QString.fromUtf8
  except AttributeError:
      def _fromUtf8(s):
          return s
  
  try:
      _encoding = QtGui.QApplication.UnicodeUTF8
      def _translate(context, text, disambig):
          return QtGui.QApplication.translate(context, text, disambig, _encoding)
  except AttributeError:
      def _translate(context, text, disambig):
          return QtGui.QApplication.translate(context, text, disambig)
  
  class Ui_Dialog(object):
  
      def save_data(self):
          d= self.lineEdit.text()
          print(d)
  
      def setupUi(self, Dialog):
          Dialog.setObjectName(_fromUtf8("Dialog"))
          Dialog.resize(397, 219)
          self.pushButton = QtGui.QPushButton(Dialog)
          self.pushButton.setGeometry(QtCore.QRect(110, 100, 112, 34))
          self.pushButton.setObjectName(_fromUtf8("pushButton"))
          self.lineEdit = QtGui.QLineEdit(Dialog)
          self.lineEdit.setGeometry(QtCore.QRect(110, 60, 113, 27))
          self.lineEdit.setText(_fromUtf8(""))
          self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
  
          self.retranslateUi(Dialog)
          QtCore.QMetaObject.connectSlotsByName(Dialog)
  
      def retranslateUi(self, Dialog):
          Dialog.setWindowTitle(_translate("Dialog", "Dialog", None))
          self.pushButton.setText(_translate("Dialog", "B2", None))
          self.pushButton.clicked.connect(self.save_data)
  
  if __name__ == "__main__":
      import sys
      app = QtGui.QApplication(sys.argv)
      Dialog = QtGui.QDialog()
      ui = Ui_Dialog()
      ui.setupUi(Dialog)
      Dialog.show()
      sys.exit(app.exec_())
  </code></pre>
  
  <p>this is the dialog file code</p>
  
  <p>i have a main window form which has a lineedit l1 and a button B1 on it.
  on clicking the button B1 a new dialog window opens.
  dialog window has a lineedit l2 and a button B2. 
  i write something in the l2 and then click b2 in dialog window.
  how can  i send my data in l2 on clicking b2 to l1 in mainwindow and also close dialog window after button b2 click and return control to mainwindow </p>