title: QWidget: Must construct a QApplication before a QPaintDevice python
body: <p>I import another Python module in my pyqt code file to get inputs and show output. but it gives me error </p>
  
  <blockquote>
    <p>QWidget: Must construct a QApplication before a QPaintDevice</p>
  </blockquote>
  
  <p>My code is:</p>
  
  <pre><code>from PyQt4 import QtGui
  import sys
  from untitled import Ui_MainWindow
  from PyQt4.QtCore import SIGNAL
  from PyQt4.QtGui import QDialog, QApplication, QPushButton, QLineEdit, QFormLayout
  from naivebase import *
  
  
  class Main (QtGui.QMainWindow):
      def __init__(self):
          QtGui.QMainWindow.__init__(self)
          self.ui = Ui_MainWindow()
          self.ui.setupUi(self)
          self.ui.pushButton.clicked.connect(self.pushButton_clicked)
          self.ui.lineEdit.returnPressed.connect(self.pushButton_clicked)
          # self.connect(QPushButton(), SIGNAL("clicked()"),  self.pushButton_clicked)
  
      def pushButton_clicked(self):
           text1 = self.ui.lineEdit.text()
           # print text1
           ob2 = TweetClassfier()
           txt = ob2.lbl1
           self.ui.label_2.setText(txt)
  
  
  if __name__ == "__main__":
      app = QtGui.QApplication(sys.argv)
      window = Main()
      window.show()
      sys.exit(app.exec_())
  </code></pre>
  
  <p>I have debugged the code it gives me this error after this line </p>
  
  <pre><code>QtGui.QMainWindow.__init__(self)
  </code></pre>