Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QQuickCloseEvent Undefined Type?
Qt 6.11 is out! See what's new in the release blog

QQuickCloseEvent Undefined Type?

Scheduled Pinned Locked Moved Solved Qt for Python
2 Posts 1 Posters 1.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Brian_Atakama
    wrote on last edited by
    #1

    I am doing some refactoring of my QML and Python source to eliminate redundancy and condense the code base, and I noticed that this seemly innocuous change does not work.

    The original QML files for Window components (Qt Quick 2 widgets) would register signal handlers for the closing signal as follows:
    onClosing: handler_fn()

    Rather than have every Window need to declare this handler, I tried to connect to this signal in Python using window.closing.connect(callback), however that doesn't seem to work. I see the following error in the logs: TypeError: Can't call meta function because I have no idea how to handle QQuickCloseEvent*

    Looking at the Qt source, it seems that the QQuickCloseEvent type is undefined in PySide2, even though it isn't listed in the list of missing bindings.

    Am I missing something here? How can I connect to this signal in Python?

    Here's a test script to reproduce the issue:

    from PySide2.QtWidgets import QApplication
    from PySide2.QtQuick import QQuickWindow
    
    def on_close(_):
        print('Closing window')
    
    def mk_app():
        app = QApplication()
        app.setQuitOnLastWindowClosed(True)
        wnd = QQuickWindow()
        wnd.closing.connect(on_close)
        wnd.show()
        app.exec_()
    
    if __name__ == '__main__':
        mk_app()
    
    1 Reply Last reply
    0
    • B Offline
      B Offline
      Brian_Atakama
      wrote on last edited by Brian_Atakama
      #2

      I actually figured out a method. Turns out QQuickCloseEvent is a private type, so this was never going to work.

      My solution is to simply use a event handler in the qml itself:

      Window {
          onClosing: do_stuff()
          ...
      }
      
      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt
      • Unsolved