Hi,
I did a sample test for learning thread.I have the follwoing code but for saome reson the wait or busy dialog does not run properly.I have attached a video where you can see dialog initialize hangs https://youtu.be/mjpnrLUx1VI.Here is the sample code:-

Main Window.cpp
Qt Code:
  1. MainWindow::MainWindow(QWidget *parent) :
  2. QMainWindow(parent),
  3. ui(new Ui::MainWindow),m_count(0)
  4. {
  5. ui->setupUi(this);
  6.  
  7. QThread* thread = new QThread;
  8. Worker* worker = new Worker();
  9. m_dialog = new WaitOrBusyDialog; //A custom class to busy dialog
  10.  
  11. worker->moveToThread(thread);
  12. connect(worker, SIGNAL(error(QString)), this, SLOT(errorString(QString)),Qt::QueuedConnection);
  13. connect(thread, SIGNAL(started()), worker, SLOT(process()),Qt::QueuedConnection);
  14. connect(worker,SIGNAL(showDialog()),this,SLOT(onDi alog()),Qt::QueuedConnection);
  15. connect(worker, SIGNAL(finished()), thread, SLOT(quit()),Qt::QueuedConnection);
  16. connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater()),Qt::QueuedConnection);
  17. connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()),Qt::QueuedConnection);
  18. thread->start();
  19.  
  20. }
  21.  
  22. MainWindow::~MainWindow()
  23. {
  24. delete ui;
  25. }
  26.  
  27. void MainWindow::onDialog()
  28. {
  29. m_dialog->show();
  30. }
To copy to clipboard, switch view to plain text mode 

WorkerThread.cpp
Qt Code:
  1. void Worker::process() {
  2. qApp->processEvents();
  3. int i=0;
  4. emit showDialog();
  5. while(i<10000)
  6. {
  7. qApp->processEvents();
  8. qDebug("Hello World!");
  9. i++;
  10. }
  11. emit finished();
  12. }
To copy to clipboard, switch view to plain text mode 

This is just a sample code to know simultanoeusly backgroud (debug output) and ui foreground process.The problem is why initially dialog hangs.