1#ifndef _PYTHONQTOBJECTPTR_H
2#define _PYTHONQTOBJECTPTR_H
50#include <QVariantList>
67 setObject(
p.object());
72 : _object(
p.takeObject())
101 setObject(
p.object());
111 _object =
p.takeObject();
138 bool isNull()
const {
return !object(); }
209 setObject(
p.object());
215 setObject(
p.object());
227 : _object(
p.takeObject())
237 setObject(
p.object());
243 setObjectUnsafe(
p.object());
262 setObjectUnsafe(
nullptr);
264 _object =
p.takeObject();
282 bool isNull()
const {
return !object(); }
PyObject * PythonQtConvertPairToPython(const void *inPair, int metaTypeId)
a smart pointer that stores a PyObject pointer and that handles reference counting automatically
PyObject * operator->() const
QVariant call(const QVariantList &args=QVariantList(), const QVariantMap &kwargs=QVariantMap())
call the contained python object directly, returns the result converted to a QVariant
PythonQtObjectPtr & operator=(const PythonQtObjectPtr &p)
PythonQtObjectPtr(PythonQtObjectPtr &&p) noexcept
rvalue copy constructor, does not need any incref/decref.
void setObject(PyObject *o)
void addVariable(const QString &name, const QVariant &v)
add the given variable to the module
PythonQtObjectPtr & operator=(PyObject *o)
void evalFile(const QString &filename)
evaluates the given code in the context
PythonQtObjectPtr & operator=(const QVariant &variant)
PythonQtObjectPtr(PyObject *o)
PythonQtObjectPtr(const PythonQtObjectPtr &p)
PythonQtObjectPtr(PythonQtSafeObjectPtr &&p)
rvalue copy constructor, does not need any incref/decref.
PyObject & operator*() const
QVariant toLocalVariant()
Returns a PythonQtObjectPtr as a QVariant. Only use this when you know that the variant is only used ...
PythonQtObjectPtr & operator=(PythonQtObjectPtr &&p) noexcept
rvalue assignment operator that steals the reference from p
bool operator==(PyObject *p) const
PythonQtObjectPtr & operator=(PythonQtSafeObjectPtr &&p)
rvalue assignment operator that steals the reference from p
QVariant evalScript(const QString &script, int start=Py_file_input)
evaluates the given script code in the context of this object and returns the result value
void removeVariable(const QString &name)
remove the given variable
PythonQtObjectPtr(const QVariant &variant)
If the given variant holds a PythonQtObjectPtr, extract the value from it and hold onto the reference...
bool operator!=(PyObject *p) const
bool operator!=(const PythonQtObjectPtr &p) const
QVariant toVariant()
Returns a PythonQtSafeObjectPtr as a QVariant. It does not return a PythonQtObjectPtr,...
void addObject(const QString &name, QObject *object)
add the given object to the module as a variable with name (it can be removed via clearVariable)
bool fromVariant(const QVariant &variant)
If the given variant holds a PythonQtObjectPtr, extract the value from it and hold onto the reference...
QVariant getVariable(const QString &name)
get the variable with the name of the module, returns an invalid QVariant on error
PyObject * object() const
QVariant call(const QString &callable, const QVariantList &args=QVariantList(), const QVariantMap &kwargs=QVariantMap())
call the given python object (in the scope of the current object), returns the result converted to a ...
bool operator==(const PythonQtObjectPtr &p) const
QVariant evalCode(PyObject *pycode)
void setNewRef(PyObject *o)
sets the object and passes the ownership (stealing the reference, in Python slang)
a smart pointer that stores a PyObject pointer and that handles reference counting automatically
void setObject(PyObject *o)
PythonQtSafeObjectPtr & operator=(PythonQtSafeObjectPtr &&p) noexcept
rvalue assignment operator that steals the reference from p
PyObject * operator->() const
void setObjectUnsafe(PyObject *o)
PythonQtSafeObjectPtr(PythonQtSafeObjectPtr &&p) noexcept
rvalue copy constructor, does not need any incref/decref.
PythonQtSafeObjectPtr(const PythonQtSafeObjectPtr &p)
PythonQtSafeObjectPtr & operator=(const PythonQtObjectPtr &p)
bool operator!=(PyObject *p) const
PythonQtSafeObjectPtr(PyObject *o)
PythonQtSafeObjectPtr(PythonQtObjectPtr &&p)
rvalue copy constructor, does not need any incref/decref.
PyObject * object() const
PyObject & operator*() const
bool operator==(PyObject *p) const
PythonQtSafeObjectPtr(const PythonQtObjectPtr &p)
PythonQtSafeObjectPtr & operator=(PythonQtObjectPtr &&p)
rvalue assignment operator that steals the reference from p
PythonQtSafeObjectPtr & operator=(PyObject *o)
PythonQtSafeObjectPtr & operator=(const PythonQtSafeObjectPtr &p)
bool operator!=(const PythonQtSafeObjectPtr &p) const
bool operator==(const PythonQtSafeObjectPtr &p) const