PDA

View Full Version : signals when closing QMainWindow



qmonkey
6th January 2010, 21:12
Does anybody know what signal QMainWindow sends out when you close it by the following methods:

1. double click the upper-left corner of a QMainWindow, or
2. left click the upper-left corner of a QMainWindow, then select Close()

I was unable to catch destroyed() signal, I didn't get any closeEvent as well.

The reason for my question is when my main window (QMainWindow) is closed though above method, other windows( generated from main window, but not necessarily child of QMainWindow) are still running. What I want is every window closed when QMainWindow is closed.

Thanks in advance!

nikhilqt
7th January 2010, 09:04
One solution for what you want is,

Make the window/widget to modality, such that users cannot able to close the mainwindow until you close the other.

Check Qt::WindowModality.

And also,
I have implemented in my application, when you hit,

1. double click the upper-left corner of a QMainWindow, or
2. left click the upper-left corner of a QMainWindow, then select Close()

It calls closeEvent(...). you need to relook into its implementation.

faldzip
7th January 2010, 09:18
Just reimplement closeEvent() in you QMainWindow subclass and close your widgets there.
There is example code in QWidget::closeEvent() documentation,

qmonkey
7th January 2010, 15:50
Thank you all for the reply!

Reimplement closeEvent() solved the problem.