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:
class A
{
bool ready = false;
public:
void get_something()
{
while(!ready)
QThread::currentThread()->
[B
]get_event_loop
()[/B
]->processEvents
();
//tadaa! now we have what we were waiting for!
//...
return xyz;
}
public slots:
//this slot is connected to the stdout output of a QProcess
void set_something(...)
{
ready = true;
//...
}
};
class A
{
bool ready = false;
public:
void get_something()
{
while(!ready)
QThread::currentThread()->[B]get_event_loop()[/B]->processEvents();
//tadaa! now we have what we were waiting for!
//...
return xyz;
}
public slots:
//this slot is connected to the stdout output of a QProcess
void set_something(...)
{
ready = true;
//...
}
};
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?
Bookmarks