title: PyQt QProgressDialog displays as an empty, white window
body: <p>I have this simple program where I want to have a modal, non-blocking progress window (using a QProgressDialog) that is remotely updated. <code>SIZE</code> simply controls the maximum value of the QProgressDialog. However, if I set it to have a value of 4 or less, the window looks like this during the entire duration of the action:</p>
  
  <p><a href="https://i.stack.imgur.com/soytw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/soytw.png" alt="enter image description here"></a></p>
  
  <p>In other words, the window is completely white and displays no text nor progress bar. If I set the value of <code>SIZE</code> to 5 or more, the display works correctly, but only after the 2-3 first iterations:</p>
  
  <p><a href="https://i.stack.imgur.com/soytw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/soytw.png" alt="enter image description here"></a> </p>
  
  <p>and later</p>
  
  <p><a href="https://i.stack.imgur.com/9hUW8.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9hUW8.png" alt="enter image description here"></a></p>
  
  <pre><code>import sys, time
  from PyQt5.QtWidgets import *
  from PyQt5.QtCore import *
  from PyQt5.QtGui import *
  
  SIZE = 5
  
  def doGenerate(setValue):
      for x2 in range(SIZE):
          time.sleep(1)
          setValue(x2 + 1)
      print('Done')
  
  
  class MainMenu(QMainWindow):
      def __init__(self):
          super().__init__()
  
          self.genAudioButton = QPushButton('Generate', self)
          self.genAudioButton.clicked.connect(self.generate)
  
          self.setCentralWidget(self.genAudioButton)
          self.show()
  
      def generate(self):
          try:
              progress = QProgressDialog('Work in progress', '', 0, SIZE, self)
              progress.setWindowTitle("Generating files...")
              progress.setWindowModality(Qt.WindowModal)
              progress.show()
              progress.setValue(0)
              doGenerate(progress.setValue)
          except Exception as e:
              errBox = QMessageBox()
              errBox.setWindowTitle('Error')
              errBox.setText('Error: ' + str(e))
              errBox.addButton(QMessageBox.Ok)
              errBox.exec()
              return
  
  if __name__ == '__main__':
      app = QApplication(sys.argv)
      ex = MainMenu()
      ret = app.exec_()
      sys.exit(ret)
  </code></pre>
  
  <p>What is causing this and how can I fix it?</p>
  
  <p><strong>Additionally</strong>, is there a way to completely remove the cancel button, instead of having an empty button that <em>still</em> cancels the action? The PyQt4 docs (I am using PyQt5) indicate that an empty string should achieve this result, and the C++ docs for Qt5 indicate the same, but that clearly doesn't work here. I haven't found standalone documentation for PyQt5.</p>