I have an app that first displays a splash page with a QPushButton labeled "Start" on it. Nothing happens until user clicks the Start button. Once clicked, the splash page disappears and the data files/modules begin loading -- and there is about a 4 second delay until the Mainwindow appears. I wanted to add either a QprogressBar or a QProgressDialog, and chose the QProgressDialog only because it seems to do what I want without adding a widget somewhere. I don't know if I made the right choice.

Here is my code for the Start Button:
Qt Code:
  1. def start(self):
  2. self.accept()
  4. self.progress = QProgressDialog()
  5. self.timer = QBasicTimer()
  6. self.progress.setMinimum(0)
  7. self.progress.setMaximum(100)
  8. self.progress.setLabelText("Loading file")
  9. self.progress.setCancelButton(None)
  10. self.progress.setValue(self.step)
  12. if self.timer.isActive():
  13. self.timer.stop()
  14. else:
  15. self.timer.start(100, self)
  17. def timerEvent(self, event):
  18. if self.step >= 100:
  19. self.timer.stop()
  20. return
  21. self.step = self.step + 10
  22. self.progress.setValue(self.step)
To copy to clipboard, switch view to plain text mode 

My problem is the progress bar shows up AFTER the Mainwindow has appeared -- likely because the "self.accept" starts the file loading process and when it finishes, the progress bar appears. I read about "starting another thread" issues, but don't understand and don't know if it's a good idea.

1. How do I fix?
2. Should some of the QProgressDialog setup code (minimum, max, set label, etc) be moved to my init section or is it in the right place?
3. Is the QProgressDialog process set up correctly? ie., with the timer, etc
4. Currently, my timer is simply based on showing the bar for about 4 seconds. How do I link the timer to the actual time between the Splash page disappearing and the Mainwindow appearing?