PDA

View Full Version : QAbstractEventDispatcher for WM_QUERYENDSESSION



R-Type
14th June 2013, 12:20
Hi,
I've a problem catching WM_QUERYENDSESSION inside my QAbstractEventDispatcher function. Main window implements closeEvent() with event->ignore(). This prevents application to exit on system(win) shutdown. Threrefore I've set global event filter:


QAbstractEventDispatcher::EventFilter origEventFiler;
bool testEventFilter(void *message)
{
MSG* m=static_cast<MSG*>(message);
if (m->message == WM_QUERYENDSESSION) qDebug()<<"Shutdown detected!";
if (origEventFiler) origEventFiler(message);
return false;
}
...
QAbstractEventDispatcher* d=QAbstractEventDispatcher::instance();
origEventFiler=d->setEventFilter(digicongEventFilter);

testEventFilter catches messages, but not the WM_QUERYENDSESSION. I thought message comes at first to testEventFilter() and then will be processed by Qt event loop. It seems to be not the case. How can I provide proper shutdown without changing main window code?