WhiteStork
WhiteStork

Reputation: 405

How to profile PySide2 + QML in QtCreator?

I have a PySide2 application, which uses QML to display the user interface. The application works from the command line. I can also launch it as well as debug it in QtCreator. However, when I try to run QmlProfiler, I see the following error:

:-1: error: /home/username/code/project/venv/bin/python: Error while finding module specification for 'ljsdebugger=file:/tmp/QtCreator-kVUFuF/qtcreator-freesocket.XgLEKq,block,services:CanvasFrameRate,EngineControl,DebugMessages,DebugTranslation' (ModuleNotFoundError: No module named 'ljsdebugger=file:/tmp/QtCreator-kVUFuF/qtcreator-freesocket')

I checked project's kit settings and it is using all the defaults. I could not find any relevant articles/discussions with this error message on the web. How to resolve this issue?

Upvotes: 4

Views: 938

Answers (2)

kw Ban
kw Ban

Reputation: 26

from PySide6.QtQml import QQmlDebuggingEnabler

debug = QQmlDebuggingEnabler()

it also useful in pyside6 , tks bro @WhiteStork

Upvotes: -1

WhiteStork
WhiteStork

Reputation: 405

Solving this involves two steps:

  1. Make the application debugging enabled

Add the line before QApplication is instantated:

from PySide2.QtQml import QQmlDebuggingEnabler

debug = QQmlDebuggingEnabler()
  1. Connect it to the QML Profiler

run the application with the command line parameter: -qmljsdebugger=port:10002,block with the port of your choice. Then go to Analyze>QML Profiler (Attach to Waiting Application) and choose the port you started the program with: enter image description here

This successfully connected the program to the QML Profiler.

Upvotes: 8

Related Questions