Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Signals during mainwindow.close()

I have a mainwindow and from that I call another window, I want the a a slot to get executed when the second window is closed. Is there any way to do that?

new_window = secondWindow()
new_window.show()
new_window.closed.connect(self.another function)

Is there any signal defined like this, or is there some other way to do that without closing the main window?

like image 522
Nevin Baiju Avatar asked Jun 04 '26 10:06

Nevin Baiju


1 Answers

The solution is to create a custom signal, and emit this signal in the closeEvent method:

class secondWindow(WidgetClass):
    closed = pyqtSignal()
    [...]

    def closeEvent(self, event):
        self.closed.emit()
        WidgetClass.closeEvent(self, event)
like image 60
eyllanesc Avatar answered Jun 06 '26 22:06

eyllanesc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!