PDA

View Full Version : "QObjects receive events by having QObject::event() function called" but who calls it



keshav2010
7th January 2019, 19:51
My question is, according to line
"QObjects receive events by having their QObject::event() function called"
the doubt here is, who is calling this function for each and every instance of type QObject ?

d_stranz
8th January 2019, 17:09
The Qt event loop (https://doc.qt.io/qt-5/eventsandfilters.html) is responsible for receiving hardware generated and other interrupts from the operating system and mapping them into events sent to QObjects. QObject-based classes themselves can generate software events, which are also handled by the event loop.

The app's QApplication instance starts its event loop when QApplication::exec() is called. Model QDialog and thread classes also start an event loop when their exec() or run() functions are called. Modal event loops usually take control from the main event loop, whereas thread event loops run in parallel.