a smart pointer that stores a PyObject pointer and that handles reference counting automatically More...
#include <PythonQtObjectPtr.h>
Public Member Functions | |
| PythonQtObjectPtr () | |
| PythonQtObjectPtr (const PythonQtObjectPtr &p) | |
| PythonQtObjectPtr (const QVariant &variant) | |
| If the given variant holds a PythonQtObjectPtr, extract the value from it and hold onto the reference. This results in an increment of the reference count. | |
| PythonQtObjectPtr (PyObject *o) | |
| ~PythonQtObjectPtr () | |
| bool | fromVariant (const QVariant &variant) |
| If the given variant holds a PythonQtObjectPtr, extract the value from it and hold onto the reference. This results in an increment of the reference count. | |
| PythonQtObjectPtr & | operator= (const PythonQtObjectPtr &p) |
| PythonQtObjectPtr & | operator= (PyObject *o) |
| PythonQtObjectPtr & | operator= (const QVariant &variant) |
| bool | operator== (const PythonQtObjectPtr &p) const |
| bool | operator!= (const PythonQtObjectPtr &p) const |
| bool | operator== (PyObject *p) const |
| bool | operator!= (PyObject *p) const |
| bool | isNull () const |
| PyObject * | operator-> () const |
| PyObject & | operator* () const |
| operator PyObject * () const | |
| void | setNewRef (PyObject *o) |
| sets the object and passes the ownership (stealing the reference, in Python slang) | |
| PyObject * | object () const |
| 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 | |
| QVariant | evalCode (PyObject *pycode) |
| void | evalFile (const QString &filename) |
| evaluates the given code in the context | |
| 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) | |
| void | addVariable (const QString &name, const QVariant &v) |
| add the given variable to the module | |
| void | removeVariable (const QString &name) |
| remove the given variable | |
| QVariant | getVariable (const QString &name) |
get the variable with the name of the module, returns an invalid QVariant on error | |
| QVariant | call (const QString &callable, const QVariantList &args=QVariantList()) |
| call the given python object (in the scope of the current object), returns the result converted to a QVariant | |
| QVariant | call (const QVariantList &args=QVariantList()) |
| call the contained python object directly, returns the result converted to a QVariant | |
Protected Member Functions | |
| void | setObject (PyObject *o) |
a smart pointer that stores a PyObject pointer and that handles reference counting automatically
Definition at line 52 of file PythonQtObjectPtr.h.
| PythonQtObjectPtr::PythonQtObjectPtr | ( | ) | [inline] |
Definition at line 55 of file PythonQtObjectPtr.h.
:_object(NULL) {}
| PythonQtObjectPtr::PythonQtObjectPtr | ( | const PythonQtObjectPtr & | p | ) | [inline] |
Definition at line 57 of file PythonQtObjectPtr.h.
References object().
| PythonQtObjectPtr::PythonQtObjectPtr | ( | const QVariant & | variant | ) | [inline] |
If the given variant holds a PythonQtObjectPtr, extract the value from it and hold onto the reference. This results in an increment of the reference count.
Definition at line 63 of file PythonQtObjectPtr.h.
:_object(NULL) {
fromVariant(variant);
}
| PythonQtObjectPtr::PythonQtObjectPtr | ( | PyObject * | o | ) |
| PythonQtObjectPtr::~PythonQtObjectPtr | ( | ) |
| void PythonQtObjectPtr::addObject | ( | const QString & | name, |
| QObject * | object | ||
| ) |
add the given object to the module as a variable with name (it can be removed via clearVariable)
| void PythonQtObjectPtr::addVariable | ( | const QString & | name, |
| const QVariant & | v | ||
| ) |
add the given variable to the module
| QVariant PythonQtObjectPtr::call | ( | const QString & | callable, |
| const QVariantList & | args = QVariantList() |
||
| ) |
call the given python object (in the scope of the current object), returns the result converted to a QVariant
| QVariant PythonQtObjectPtr::call | ( | const QVariantList & | args = QVariantList() | ) |
call the contained python object directly, returns the result converted to a QVariant
| QVariant PythonQtObjectPtr::evalCode | ( | PyObject * | pycode | ) |
evaluates the given code and returns the result value (use Py_Compile etc. to create pycode from string) If pycode is NULL, a python error is printed.
| void PythonQtObjectPtr::evalFile | ( | const QString & | filename | ) |
evaluates the given code in the context
| QVariant PythonQtObjectPtr::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
| bool PythonQtObjectPtr::fromVariant | ( | const QVariant & | variant | ) |
If the given variant holds a PythonQtObjectPtr, extract the value from it and hold onto the reference. This results in an increment of the reference count.
| QVariant PythonQtObjectPtr::getVariable | ( | const QString & | name | ) |
get the variable with the name of the module, returns an invalid QVariant on error
| bool PythonQtObjectPtr::isNull | ( | ) | const [inline] |
Definition at line 107 of file PythonQtObjectPtr.h.
{ return !object(); }
| PyObject* PythonQtObjectPtr::object | ( | ) | const [inline] |
Definition at line 118 of file PythonQtObjectPtr.h.
Referenced by operator=(), operator==(), and PythonQtObjectPtr().
{
return _object;
}
| PythonQtObjectPtr::operator PyObject * | ( | ) | const [inline] |
Definition at line 113 of file PythonQtObjectPtr.h.
{ return object(); }
| bool PythonQtObjectPtr::operator!= | ( | PyObject * | p | ) | const [inline] |
Definition at line 103 of file PythonQtObjectPtr.h.
{
return object() != p;
}
| bool PythonQtObjectPtr::operator!= | ( | const PythonQtObjectPtr & | p | ) | const [inline] |
Definition at line 95 of file PythonQtObjectPtr.h.
{
return !( *this == p );
}
| PyObject& PythonQtObjectPtr::operator* | ( | ) | const [inline] |
Definition at line 111 of file PythonQtObjectPtr.h.
{ return *( object() ); }
| PyObject* PythonQtObjectPtr::operator-> | ( | ) | const [inline] |
Definition at line 109 of file PythonQtObjectPtr.h.
{ return object(); }
| PythonQtObjectPtr& PythonQtObjectPtr::operator= | ( | const QVariant & | variant | ) | [inline] |
Definition at line 85 of file PythonQtObjectPtr.h.
{
fromVariant(variant);
return *this;
}
| PythonQtObjectPtr& PythonQtObjectPtr::operator= | ( | const PythonQtObjectPtr & | p | ) | [inline] |
Definition at line 74 of file PythonQtObjectPtr.h.
References object().
| PythonQtObjectPtr& PythonQtObjectPtr::operator= | ( | PyObject * | o | ) | [inline] |
Definition at line 79 of file PythonQtObjectPtr.h.
{
setObject(o);
return *this;
}
| bool PythonQtObjectPtr::operator== | ( | PyObject * | p | ) | const [inline] |
Definition at line 99 of file PythonQtObjectPtr.h.
{
return object() == p;
}
| bool PythonQtObjectPtr::operator== | ( | const PythonQtObjectPtr & | p | ) | const [inline] |
Definition at line 91 of file PythonQtObjectPtr.h.
References object().
| void PythonQtObjectPtr::removeVariable | ( | const QString & | name | ) |
remove the given variable
| void PythonQtObjectPtr::setNewRef | ( | PyObject * | o | ) |
sets the object and passes the ownership (stealing the reference, in Python slang)
| void PythonQtObjectPtr::setObject | ( | PyObject * | o | ) | [protected] |
1.7.4