Hi everybody,
if a QWidget starts his own event loop by a 'exec' statement, is the QApplication aware of it, bacuse it receives a signal or a particular event ?
Thank you in advance.
Placido.
Hi everybody,
if a QWidget starts his own event loop by a 'exec' statement, is the QApplication aware of it, bacuse it receives a signal or a particular event ?
Thank you in advance.
Placido.
yes, you are right. I try to be clearer.
My application records an array of events, every of them has his own object. When the user wants, he can play those recorded events. But, obviously, if the object, to whom the event is referenced, is modal and starts its own loop by the 'exec', the playing of the events is stopped and it continues only after the closing of the modal dialog.
So, I am wondering if it is possible to continue to send events to those modal objects.
Thanks for your help.
So how do you collect these events? By installing an event filter on the application object?
J-P Nurmi
Yes, I have an event-fitler on the application.
Does this sample reproduce the problem?
Notice how it installs an event filter on the application object but then enters to the event loop of the dialog. I can see all the events received by both - the dialog and its button child - being output.Qt Code:
#include <QtGui> #include <QtDebug> { public: { qDebug() << object << event; return false; } }; int main(int argc, char *argv[]) { Filter filter; app.installEventFilter(&filter); QDialog dialog; return dialog.exec(); }To copy to clipboard, switch view to plain text mode
J-P Nurmi
Placido Currò (31st January 2008)
Thanks.
But I still can't see the event that makes the QApplication aware of a new child's loop.
What remains is to add a postEvent statement before the qDialog->exec.
Do you have any other ideas ?
Placido.
I'm not sure if I follow. Every thread can have multiple nested event loops but a single event dispatcher. QCoreApplication creates the event dispatcher for the main thread and every QThread instance creates an event dispatcher for that particular thread. Running nested event loops is only a matter of pushing the event loop on the stack of thread's event loops and handling the event dispacther. I'd suggest taking a sneak peak to QEventLoop sources (src/corelib/kernel/qeventloop.*) which is surprisingly simple. QDialog uses QEventLoop to run its event loop.
J-P Nurmi
Placido Currò (1st February 2008)
Bookmarks