Skip to content Skip to sidebar Skip to footer

Getting Data From Child Using Pyqt

I am building a simple application that opens a QDialog, and from a QComboBox that belongs to the child, I can select an item and see some information. What I need to do is to get

Solution 1:

Generally, when you're using a temporary dialog to get information from the user, the dialog should be modal, so you can block all other actions until the user is finished with the dialog. It also allows you to call the dialog much like a function, and get results back from it.

Here is an example of a modal dialog that returns the text results.

classConfigurePort(QDialog):
    def__init__(self, parent = None):
        QDialog.__init__(self, parent)
        uic.loadUi("configurePort.ui", self)

        self.initUi()

    definitUi(self):
        self.comboBox.activated[str].connect(self.Selected)
        self.label.hide()

    defSelected(self, text):
        if text == "option 1":
            self.label.setText("Option 1 selected")

    defgetLabelText(self):
        return self.label.text()

    @classmethoddeflaunch(cls, parent=None):
        dlg = cls(parent)
        dlg.exec_()
        text = dlg.getLabelText()
        return text


classWindow(QMainWindow):
    ...
    defSerial_connection(self, event):
        text = configurePort.ConfigurePort.launch(self)
        print text

Post a Comment for "Getting Data From Child Using Pyqt"