Enabling QML debugging with Pyside2 5.11.2

  • I'm trying to enable the qml/js debugger in my PySide2 app so I can connect the QtCreator Debugger to it.

    I've done this successfully in PyQt5 where I had to build the wrapper with qml debugging enabled, and then instantiate the QApplication with the argument '-qmljsdebugger=port:3768,block'. This paused my app until I connected the QtCreator debugger to it via Debug > Start Debugging > Attach to QML Port.

    I've switched to PySide2, and it doesn't seem there is the same option to build PySide2 with debugging enabled. When I try to instantiate the QApplication with the debugger argument, I get this message: "QML Debugger: Ignoring ..... Debugging has not been enabled." which was the message I got when running against non-debugging enabled PyQt5.

    I did notice that PySide2 has a "QQmlDebuggingEnabler" class, but the documentation is very sparse. Calling QQmlDebuggingEnabler.StartTcpDebugServer(3768) before instantiating my QApplication gets rid of the "Debugging has not been enabled" message, but I'm unable to connect to the debugger with QtCreator.

    Do I need to build PySide2 with the QT_QML_DEBUG flag somehow? Is there a way I can do it without having to rebuild PySide2 by using QQmlDebuggingEnabler?


  • Figured out my issue. I just needed to instantiate a QQmlDebuggingEnabler object. Calling QtQml.QQmlDebuggingEnabler() before instantiating my QApplication was enough.

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.