You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/PythonQtDoc.h
+31-1Lines changed: 31 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -144,7 +144,7 @@ Qt framework</a>.
144
144
- PythonQt currently does not support instanceof checks for Qt classes, except for the exact match and derived Python classes
145
145
- QObject.emit to emit Qt signals from Python is not yet implemented but PythonQt allows to just emit a signal by calling it like a normal slot
146
146
- PythonQt does not (yet) offer to add new signals/slots to Python/C++ objects and it does not create QMetaObjects for derived classes on the fly
147
-
- Ownership of objects is a bit different in PythonQt, currently Python classes derived from a C++ class need to be manually referenced in Python to not get deleted too early (this will be fixed in a future version)
147
+
- Ownership handling of objects is not as complete as in PySide and PyQt, especially in situations where the ownership is not clearly passed to C++ on the C++ API.
148
148
- QStrings are always converted to unicode Python objects, QByteArray always stays a QByteArray and can be converted using QByteArray.data()
149
149
- Qt methods that take an extra "bool* ok" parameter can be called passing PythonQt.BoolResult as parameter. In PyQt, a tuple is returned instead.
150
150
@@ -420,6 +420,36 @@ yourCpp = None
420
420
421
421
\endcode
422
422
423
+
\section Ownership Ownership management
424
+
425
+
In PythonQt, each wrapped C++ object is either owned by Python or C++. When an object is created via a Python constructor,
426
+
it is owned by Python by default. When an object is returned from a C++ API (e.g. a slot), it is owned by C++ by default.
427
+
Since the Qt API contains various APIs that pass the ownership from/to other C++ objects, PythonQt needs to keep track of
428
+
such API calls. This is archieved by annotating arguments and return values in wrapper slots with magic templates:
429
+
430
+
- PythonQtPassOwnershipToCPP
431
+
- PythonQtPassOwnershipToPython
432
+
- PythonQtNewOwnerOfThis
433
+
434
+
These annotation templates work for since C++ pointer types. In addition to that, they work for QList<AnyObject*>,
435
+
to pass the ownership for each object in the list.
PythonQt requires at least Qt 4.6.1 (for earlier Qt versions, you will need to run the pythonqt_generator, Qt 4.3 is the absolute minimum) and Python 2.6.x/2.7.x or Python 3.3 (or higher).
0 commit comments