title: PyQt code doesnt work when it's inside the class
body: <p>Recently I have created an simple <code>PyQt</code> based app. All it have to do is to make a system tray icon. The problem is that I can see the application is running, however no tray icon is being made. When I move the tray icon code outside the class its <em>working</em> fine. <strong>So why is the class a problem here?</strong></p>
  
  <p><strong>My code:</strong></p>
  
  <pre><code># -*- coding: utf-8 -*-
  
  import sys
  from PyQt4 import QtGui, QtCore
  
  app = QtGui.QApplication(sys.argv)
  
  class myApp(QtGui.QWidget):
      def __init__(self):
          QtGui.QWidget.__init__(self)
          self.createTrayIcon()
  
      def createTrayIcon(self):
          self.trayIconMenu = QtGui.QMenu()
          self.trayIconMenu.addAction("Close", lambda : exit(1))
  
          self.trayIcon = QtGui.QSystemTrayIcon()
          self.trayIcon.setIcon(QtGui.QIcon(r"icon.png"))
          self.trayIcon.setToolTip("Tooltip")
          self.trayIcon.setContextMenu(self.trayIconMenu)
          self.trayIcon.show()
          self.trayIcon.showMessage("Title", u"Content")
  
  myApp()
  sys.exit(app.exec_())
  </code></pre>