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

Reg 6.6->6.7: Unable to get the QFileOpenEvent from a QEvent

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P1: Critical P1: Critical
    • 6.7.1, 6.8.0
    • 6.7.0
    • PySide
    • None
    • macOS
    • f86293210 (dev), 4a04afc95 (dev), 152ec44d1 (dev), bd786b82c (6.7), 52f5da392 (6.7), 46ea5407a (6.7), 0e107b7ec (dev), 9f09e1dda (dev), 99ea7ac4f (6.7), 3bfce0de3 (6.7), ce2959ec5 (dev), dcb3aa5de (dev), b5cbb40f4 (dev), ae23c335e (dev), a47ed06d1 (6.7)

      In PySide 6.7.0, I am no longer able to get the file path from a QFileOpenEvent. In particular, when I try to cast the event using e.g.

          def event(self, evt):
              """ Handle an application-level event """
              LOGGER.debug("Event: %s %s", evt, evt.__dir__())
              if evt.type() == QtCore.QEvent.Type.FileOpen:
                  url = QtGui.QFileOpenEvent(evt).url()
                  LOGGER.debug("Got file open event: %s %s", url, url.toLocalFile())
                  #self.open_file()
                  return True
      
              return super().event(evt)
      

      I get an error:

      Traceback (most recent call last):
        File "/Users/fluffy/projects/bandcrash/bandcrash/gui/__init__.py", line 911, in event
          url = QtGui.QFileOpenEvent(evt).url()
                ^^^^^^^^^^^^^^^^^^^^^^^^^
      TypeError: 'PySide6.QtGui.QFileOpenEvent.__init__' called with wrong argument types:
        PySide6.QtGui.QFileOpenEvent.__init__(QEvent)
      Supported signatures:
        PySide6.QtGui.QFileOpenEvent.__init__(PySide6.QtGui.QFileOpenEvent)
        PySide6.QtGui.QFileOpenEvent.__init__(str)
        PySide6.QtGui.QFileOpenEvent.__init__(Union[PySide6.QtCore.QUrl, str])
       

      I can't seem to figure out how to actually get the QFileOpenEvent from the QEvent, and the documentation isn't being particularly helpful here.

        For Gerrit Dashboard: PYSIDE-2675
        # Subject Branch Project Status CR V

            ctismer Christian Tismer
            fluffy fluffy <3
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes