Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PyQt5.QtWidgets import QApplication, QMainWindow, QDialog, QPushButton, QLineEdit, QFormLayout
- class MainWnd(QMainWindow):
- def __init__(self):
- super().__init__()
- self.button = QPushButton('Open dialog')
- self.button.clicked.connect(self.show_dialog)
- self.setCentralWidget(self.button)
- self.dlg_widget = QLineEdit('Close dialog and try to open again')
- def show_dialog(self):
- dlg = Dlg(self)
- dlg.exec_()
- class Dlg(QDialog):
- def __init__(self, parent=None):
- super().__init__(parent)
- self.layout = QFormLayout()
- self.layout.addWidget(self.parentWidget().dlg_widget)
- self.setLayout(self.layout)
- app = QApplication([])
- mwnd = MainWnd()
- mwnd.show()
- exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement