I have created a little pyqt5 project. Here is a printscreen of the application while running:
When the user clicks on the QPushButton
from the main window, the dialog window appears and the user writes something in the QlineEdit
. Then while clicking on the QPushButton
of the dialog window, the dialog window sends a signal to the main window and is deleted. The signal contains the text typed by the user.
Here are the descriptions of my two classes which are very simple:
The MainWindow class.
The DialogWindow class (I want to make my own Dialog Class without using the pre existing Dialog windows).
My main script
I have several questions:
Is it the right way of using signals in order to communicate between windows? I do not think that I violate the class encapsulation. However I do not like to connect the signal on the child class by writing:
self.mySignal.connect(parent.updatelabelAnswer)
In this line I use the attribute parent
- is it okay? It seems to me that it is not a good way to use signals.
My second question is:
Am I right to call self.deleteLater()
in the on_pushButton_clicked
slot of DialogWindow
? It seems not, as I have checked with the python interactive shell and the object myDialogWindow
is still accessible.