title: PyQt window closes immediately after opening
body: <p>I am getting an issue when trying to open a PyQt window.</p>
  <p>The code below is an example of my original code. When I imported the module in <code>import Test</code> and ran <code>test.Start()</code>, I got the following error:</p>
  <blockquote>
  <p>QCoreApplication::exec: The event loop is already running</p>
  </blockquote>
  <p>After some research, I found out it was because I had already already made a <code>QApplication</code>.</p>
  <pre><code>test.py....
  import sys
  
  def Start():
      app = QApplication(sys.argv)
      m = myWindow()
      m.show()
      app.exec_()
  
  class myWindow():....
  
  if __name__ == &quot;__main__&quot;:
      Start()
  </code></pre>
  <p>So then I read that I could rewrite my code like this and it would fix the error:</p>
  <pre><code>test.py....
  
  def Start():
      m = myWindow()
      m.show()
  
  
  class myWindow():....
  
  if __name__ == &quot;__main__&quot;:
      import sys
      app = QApplication(sys.argv)
      Start()
      app.exec_()
  </code></pre>
  <p>Now I no longer get the <strong>QCoreApplication::exec: The event loop is already running</strong> error, but my window closes almost immediately after opening.</p>