set value from filepicker to dialog that called it
<p>i have a action button that calls an dialog that i've made:</p>

<pre><code>class MainPanelManager(QtWidgets.QMainWindow, Ui_MainWindow):
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.actionLocation.triggered.connect(self.editsettings)

    def editsettings(self):
        dialog = QDialog()
        dialog.ui = Ui_Dialog()
        dialog.ui.setupUi(dialog)
        dialog.ui.pushButton.clicked.connect(self.openfile)
        dialog.exec_()


    def openfile(self):
        folder = QFileDialog.getExistingDirectory(self, 'Select Folder', 'C:/')
        # folder value must be set to dialog textedit
</code></pre>

<p>Dialog works and opens file picker when button is pressed. How to set the value when folder is selected. I need to put the value in <code>textedit</code></p>

<p>A simple solution would be declaring the <code>dialog</code> variable a property of <code>self</code> object. So, you can then use it class-widely in all methods.</p>

<pre><code>class MainPanelManager(QtWidgets.QMainWindow, Ui_MainWindow):
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.actionLocation.triggered.connect(self.editsettings)

    def editsettings(self):
        self.dialog = QDialog()
        self.dialog.ui = Ui_Dialog()
        self.dialog.ui.setupUi(dialog)
        self.dialog.ui.pushButton.clicked.connect(self.openfile)
        self.dialog.exec_()


    def openfile(self):
        folder = QFileDialog.getExistingDirectory(self, 'Select Folder', 'C:/')
        # folder value must be set to dialog textedit
        self.dialog.ui.textedit.set_text(folder)
</code></pre>

python qt python-3.x pyqt qt-creator