Skip to content
Discussion options

You must be logged in to vote

This is somewhat expected. Objects in Python are reference-counted. If the reference count goes down to zero, the object is deleted.

In the case of Python objects, the reference count is increased by the PythonQtObjectPtr stored in the QVariant.

For the C++ object, there is no extra reference count. After the C++ object is returned from the evalScript method, the scope of the Python code is deleted, the reference count of the wrapper goes back zero, and the wrapper and its wrapped object are deleted.

There are two things you can do:

  • Store a reference to the object in Python. Create a new Python module or "re-use" an existing one, and store your object in it. This way there will be a rema…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mrbean-bremen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #259 on September 30, 2025 14:51.