Jason Hamilton
3rd September 2008, 18:38
Hey all, much thanks for the quick responses previously. I have another question that may be in the docs, but I can't find it. I have also been unable to get any results from the search here.
If I have a program in which main() owns a pointer to a QApplication object. Nested into that window is a Controller_GUI class which controls a mainWindow object (these are custom classes). What I am trying to accomplish is to write a function that saves the state of the software when the user quits. I have accomplished this when the user quits by way of the menu, but that function doesn't fire when the use the 'X' in the top-right of the window, as during normal Windows operation. I found that QApplication emits a SIGNAL, aboutToClose() which, as I understand it, fires just before the program exits. I tried using connect on the mainWindow object and it doesn't appear to work, given that QMainWindow doesn't appear to inherit the aboutToClose SIGNAL from QApplication.
My initial thought was to use the connect function in main, but I can't get it to call the function because the SLOT isn't defined. Should I derive a class from QApplication? It seems to me that there should be a better way to do this. Any hwlp would be greatly appreciated.
Jason
If I have a program in which main() owns a pointer to a QApplication object. Nested into that window is a Controller_GUI class which controls a mainWindow object (these are custom classes). What I am trying to accomplish is to write a function that saves the state of the software when the user quits. I have accomplished this when the user quits by way of the menu, but that function doesn't fire when the use the 'X' in the top-right of the window, as during normal Windows operation. I found that QApplication emits a SIGNAL, aboutToClose() which, as I understand it, fires just before the program exits. I tried using connect on the mainWindow object and it doesn't appear to work, given that QMainWindow doesn't appear to inherit the aboutToClose SIGNAL from QApplication.
My initial thought was to use the connect function in main, but I can't get it to call the function because the SLOT isn't defined. Should I derive a class from QApplication? It seems to me that there should be a better way to do this. Any hwlp would be greatly appreciated.
Jason