I have a QThread running, which receives signals from a QProcess (asynchronously). Now I want to "block" a function executing in the context of that thread, until the same thread has received a certain signal from the process.


I would imagine it something like this:


Qt Code:
  1. class A
  2. {
  3. bool ready = false;
  4. public:
  5.  
  6. void get_something()
  7. {
  8. while(!ready)
  9. QThread::currentThread()->[B]get_event_loop()[/B]->processEvents();
  10.  
  11. //tadaa! now we have what we were waiting for!
  12. //...
  13. return xyz;
  14. }
  15.  
  16. public slots:
  17. //this slot is connected to the stdout output of a QProcess
  18. void set_something(...)
  19. {
  20. ready = true;
  21. //...
  22. }
  23.  
  24. };
To copy to clipboard, switch view to plain text mode 

(Note that both get_something() and set_something() live in the same thread)

Problem is that QThread does not have a method to access its QEventLoop!

Any ideas?




----------

As an aside: Currently the GUI thread is the only thread involved (imagine get_something() being something like a buttonpress-event). So I could do QApplicatoin:rocessAllEvents(). But this got me wondering, what if it is not the GUI thread, but any generic QThread? How to access its event loop?