I have QThread-derived class (downloader) that has to download several files from the server sequentially. I post an event to the thread instance from main to start download, and then I am trying to post event to the thread (now a QEventLoop) for the next download. My question is: how to post the event from "within" the thread?
{
public:
void run() {
exec();
}
//process download
...
//code breaks here. Question - how to post an event?
}
}
int main()
{
T t;
t.start();
...
}
class T : public QThread
{
public:
void run() {
exec();
}
bool event (QEvent* event) {
//process download
...
//code breaks here. Question - how to post an event?
QApplication::instance()->postEvent(this, new userEvent());
}
}
int main()
{
T t;
t.start();
QApplication::instance()->postEvent(&t, new userEvent());
...
}
To copy to clipboard, switch view to plain text mode
Bookmarks