try overriding QApplication::commitData it should be called whenever user shuts down the system and your application is still running.
This function deals with session
management. It is invoked when the
QSessionManager wants the application
to commit all its data.
Usually this means saving all open
files, after getting permission from
the user. Furthermore you may want to
provide a means by which the user can
cancel the shutdown.
below is an example (never tried it with macs; though works fine on my ubuntu):
main.cpp:
#include <QtGui/QApplication>
#include "mainwindow.h"
#include <QSessionManager>
class MyApplication : public QApplication
{
public:
MyApplication(int &argc, char **argv);
virtual void commitData(QSessionManager& sm);
};
MyApplication::MyApplication(int &argc, char **argv):
QApplication(argc, argv)
{
//???
}
void MyApplication::commitData(QSessionManager& sm)
{
// do smth here....
QApplication::commitData(sm);
}
int main(int argc, char *argv[])
{
MyApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
hope this helps, regards