Question: How for force deletion of a child QObject? #198
Unanswered
rainman110
asked this question in
Q&A
Replies: 1 comment 1 reply
-
If I read this correctly this else branch should be used automatically if you didn't specify a "py_delete" slot method in your QObject. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Lets assume, I have a object hierarchy
Parent
|--> child
Parent
is currently managed by C++ and thuschild
as well. Now lets assume a python functionget_child
, that returns the child.Now I'd like to make PythonQt the owner of the returned child object, meaning that when the returned object is deleted by python, also the child should be deleted and removed from its parent automatically. Here's the example to be more precise
The function
PythonQtInstanceWrapper_deleteObject
is used as a destructor of QObject-type python objects. Inside this function, the code to free the underlying QObject is the followingpythonqt/src/PythonQtInstanceWrapper.cpp
Lines 105 to 109 in 3cc771c
As you can see, the existence of a parent ensures, that the child is not deleted, even if PythonQt has ownership. This makes sense in most cases. This destructor function though has a
force
argument, which I'd like to use. How can I make sure, that the force argument is set to true?A hint in the PythonQt code is
pythonqt/src/PythonQtInstanceWrapper.cpp
Lines 344 to 356 in 3cc771c
which forces object destruction, if
deleteSlot._type != PythonQtMemberInfo::Slot
. What does this mean? Is there any way to exploit this?Beta Was this translation helpful? Give feedback.
All reactions