1#ifndef _PYTHONQTOBJECTPTR_H
2#define _PYTHONQTOBJECTPTR_H
50#include <QVariantList>
63 setObject(
p.object());
68 :_object(
p.takeObject()) {
93 setObject(
p.object());
102 _object =
p.takeObject();
122 return object() ==
p.object();
126 return !( *
this ==
p );
130 return object() ==
p;
134 return object() !=
p;
137 bool isNull()
const {
return !object(); }
204 setObject(
p.object());
209 setObject(
p.object());
214 :_object(
p._object) {
220 :_object(
p.takeObject()) {
228 setObject(
p.object());
233 setObjectUnsafe(
p.object());
250 setObjectUnsafe(
nullptr);
252 _object =
p.takeObject();
262 return object() ==
p.object();
266 return !(*
this ==
p);
270 return object() ==
p;
274 return object() !=
p;
277 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...
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)
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