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?

Qt Code:
  1. class T : public QThread
  2. {
  3. public:
  4. void run() {
  5. exec();
  6. }
  7. bool event (QEvent* event) {
  8. //process download
  9. ...
  10.  
  11. //code breaks here. Question - how to post an event?
  12. QApplication::instance()->postEvent(this, new userEvent());
  13. }
  14. }
  15.  
  16. int main()
  17. {
  18. T t;
  19. t.start();
  20. QApplication::instance()->postEvent(&t, new userEvent());
  21. ...
  22. }
To copy to clipboard, switch view to plain text mode