Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1521

closeEvent() not sent if QApplication isn't in main thread

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 6.0.2
    • PySide
    • None
    • PySide 6.0.2
      Python 3.8.8
      Windows 10 build 19042.804
    • Windows

    Description

      I do quite a bit of prototyping from Jupyter Lab.   It is important to me that Jupyter remains interactive while I manipulate widgets that I am developing, or widgets that I am using to manipulate my data.  In order for that to happen, Jupyter needs the main thread.  And so, I run my QApplication from a QThread.

      I've noticed when clicking the window close button (top right 'X') that my windows do not close.  So far, I've established that closeEvent() is not getting called.  On the other hand, if QApplication.exec_() is called from the main thread, they close just fine.  I think this is a bug in the widget (gui) event handling system.  (I've confirmed that it does this even if I'm not running from Jupyter, just to rule that out.)

      It's my understanding that QApplication prefers the main thread, but shouldn't need it.  (It issues a warning to the console, but seems to work.)  If that is the case, then this is a bug.  Otherwise, consider this a feature request.

       

      This closes fine:

      from PySide6 import QtWidgets
      app = QtWidgets.QApplication()
      label = QtWidgets.QLabel('Hello World')
      label.show()
      app.exec_()

       

      This does not close:

      from time import sleep
      from PySide6 import QtCore, QtWidgets
      class ExampleThread (QtCore.QThread):
          def run(self) :
              app = QtWidgets.QApplication()
              label = QtWidgets.QLabel('Hello World')
              label.show()
              app.exec_()
      example = ExampleThread()
      example.start()
      sleep (7*24*60*60)

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              crmaurei Cristian Maureira-Fredes
              gd2shoe Jason Ivy
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes