You should provide example code to help people understand your question. At least mention that you are using some version of Qt.
from PySide6 import QtWidgets, QtCore
class FormB(QtWidgets.QWidget):
form_done = QtCore.Signal(str)
def __init__(self, *args, steps=5, **kwargs):
super().__init__(*args, **kwargs)
self.entry = QtWidgets.QLineEdit("Enter value here")
self.button = QtWidgets.QPushButton("Done")
self.button.clicked.connect(self.button_pressed)
layout = QtWidgets.QVBoxLayout(self)
layout.addWidget(self.entry)
layout.addWidget(self.button)
def button_pressed(self):
self.hide()
self.form_done.emit(self.entry.text())
class FormA(QtWidgets.QWidget):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.form_b = None
self.button = QtWidgets.QPushButton("Draw B")
self.button.clicked.connect(self.draw_b)
self.label = QtWidgets.QLabel("I display the result in this label")
layout = QtWidgets.QVBoxLayout(self)
layout.addWidget(self.button)
layout.addWidget(self.label)
def draw_b(self):
if self.form_b is None:
self.form_b = FormB()
self.form_b.form_done.connect(self.b_done)
self.form_b.show()
def b_done(self, text):
self.label.setText(text)
def main():
app = QtWidgets.QApplication([])
form_a = FormA()
form_a.show()
app.exec()
main()
Any python function/method can be bound to a signal, so the concept of Slots is kind of meaningless.