Hi guys im having kind of a headache understanding threads in Qt.
I`ve already read some post about QThread and the You are doing it blog entry but somehow I cant understand the full concep...
My idea is to show a loading widget while i load my application data. So far I ve the following code:

Qt Code:
  1. #include <QtGui/QApplication>
  2. #include <QObject>
  3. #include "waitthread.h"
  4. #include "loadthread.h"
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8. QApplication a(argc, argv);
  9. QApplication::setStyle (new IconSize ());
  10.  
  11. LoadThread * load_thread = new LoadThread ();
  12. WaitThread * wait_thread = new WaitThread ();
  13.  
  14. QObject::connect (load_thread, SIGNAL(load_finished()), wait_thread, SLOT(loading_finished()));
  15.  
  16. load_thread->start ();
  17. wait_thread->start ();
  18.  
  19. return a.exec ();
  20. }
To copy to clipboard, switch view to plain text mode 

the loadthread.cpp:

Qt Code:
  1. LoadThread::LoadThread()
  2. {
  3. mainWin = new MainWindow ();
  4. }
  5.  
  6. void LoadThread::run (){
  7. //--------------------do some stuff
  8. emit load_finished ();
  9. emit load_finished ();
  10. show_mainWin ();
  11. }
  12.  
  13. void LoadThread::show_mainWin (){
  14. mainWin->show ();
  15. }
To copy to clipboard, switch view to plain text mode 

And the waitThread.cpp

Qt Code:
  1. #include "waitthread.h"
  2.  
  3. WaitThread::WaitThread()
  4. {
  5. loadwidg = new LoadingWidget ();
  6. loadwidg->show ();
  7. }
  8.  
  9. void WaitThread::run (){
  10. }
  11.  
  12. void WaitThread::loading_finished (){
  13. loadwidg->close ();
  14. delete loadwidg;
  15. this->terminate ();
  16. }
To copy to clipboard, switch view to plain text mode 


I think that the signal is received because the loading widget is closed...but mainWin only pops up for a split sec, like the object Qthread is destroyed...I know that im designing this the wrong way...hope someone can give a hand to fully understand this...