title: PyQt5 tray program closes after QDialog executing
body: <pre><code>from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QGridLayout, QWidget, QCheckBox, QSystemTrayIcon, \
      QSpacerItem, QSizePolicy, QMenu, QAction, QStyle, qApp, QPushButton
  from PyQt5.QtCore import QSize
  from PyQt5 import QtWidgets
  
  
  class MainWindow(QMainWindow):
      check_box = None
      tray_icon = None
  
      def __init__(self):
  
          QMainWindow.__init__(self)
  
          self.setMinimumSize(QSize(480, 80))
          self.setWindowTitle(&quot;System Tray Application&quot;)
          central_widget = QWidget(self)
          self.setCentralWidget(central_widget)
  
          grid_layout = QGridLayout(self)
          central_widget.setLayout(grid_layout)
          grid_layout.addWidget(QLabel(&quot;Application, which can minimize to Tray&quot;, self), 0, 0)
  
          self.check_box = QCheckBox('Minimize to Tray')
          grid_layout.addWidget(self.check_box, 1, 0)
          grid_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding), 2, 0)
  
          self.btn = QPushButton('Dialog', self)
          grid_layout.addWidget(self.btn, 1, 1)
          self.btn.clicked.connect(self.dial_func)
  
          self.tray_icon = QSystemTrayIcon(self)
          self.tray_icon.setIcon(self.style().standardIcon(QStyle.SP_ComputerIcon))
  
          show_action = QAction(&quot;Show&quot;, self)
          quit_action = QAction(&quot;Exit&quot;, self)
          hide_action = QAction(&quot;Hide&quot;, self)
          dial = QAction('Dial', self)
          dial.triggered.connect(self.dial_func)
          show_action.triggered.connect(self.show)
          hide_action.triggered.connect(self.hide)
          quit_action.triggered.connect(qApp.quit)
  
          tray_menu = QMenu()
          tray_menu.addAction(show_action)
          tray_menu.addAction(hide_action)
          tray_menu.addAction(dial)
          tray_menu.addAction(quit_action)
          self.tray_icon.setContextMenu(tray_menu)
          self.tray_icon.show()
  
      def closeEvent(self, event):
          if self.check_box.isChecked():
              event.ignore()
              self.hide()
              self.tray_icon.showMessage(
                  &quot;Tray Program&quot;,
                  &quot;Application was minimized to Tray&quot;,
                  QSystemTrayIcon.Information,
                  2000
              )
  
      def dial_func(self):
          text, ok = QtWidgets.QInputDialog.getText(self, 'Input dialog', 'Enter your name')
  
          if ok:
              print('simple text', text)
  
  
  if __name__ == &quot;__main__&quot;:
      import sys
  
      app = QApplication(sys.argv)
      mw = MainWindow()
      mw.show()
      sys.exit(app.exec())
  
  </code></pre>
  <p>I am trying to write little application for diagnostic. Application should work in tray and have options to change settings from QDialog.
  With this code, I can run dialog from btn (in main window) and from Dial (from QMenu). And if program not in tray, everything works fine, but if it's in tray, program finishes. What's way to solve this problem?</p>