QPy
Python-Qt dynamic bindings
 All Classes Namespaces Files Functions
Classes | Public Member Functions | Static Public Member Functions
qpy::PyContext Class Reference

Python-Qt context manager. Helper methods for Qt-Python interaction. More...

#include <PyContext.h>

List of all members.

Classes

class  ArgFactoryEntry
struct  ConnectEntry
struct  Method
 Stores information used at method invocation time.
struct  PyQObject
 PyObject type More...
struct  Type
 Stores type information needed for invoking methods from Python. More...
struct  TypeConstruction
 Stores information on registered types. More...

Public Member Functions

 PyContext ()
 Constructor: Create qpy module with QPy interface.
 ~PyContext ()
void AddGlobals (PyObject *module)
 Add QPy globals to Python interpreter; currently only __version__ is added.
PyTypeObject * AddType (const QMetaObject *mo, PyObject *module, bool checkConstructor=true, const QSet< QString > &selectedMembers=QSet< QString >(), const PyMemberNameMapper &mm=DefaultMemberNameMapper(), const char *className=0, const char *doc=0)
template<typename T >
void Add (PyObject *module, bool checkConstructor=true, const QSet< QString > &selectedMembers=QSet< QString >(), const PyMemberNameMapper &mm=DefaultMemberNameMapper(), const char *className=0, const char *doc=0)
PyMethodDef * ModuleFunctions ()
PyObject * AddObject (QObject *qobj, PyObject *targetModule, PyObject *typeModule, const char *instanceName, bool pythonOwned=false, const QSet< QString > &selectedMembers=QSet< QString >(), const PyMemberNameMapper &mm=DefaultMemberNameMapper())
 Add pre-existing QObject instance to Python module.
template<typename QArgConstructorT , typename PyArgConstructorT >
bool RegisterType (const QString &typeName, bool overwrite=false)
template<typename T , typename QArgConstructorT , typename PyArgConstructorT >
bool RegisterType (const QString &typeName, bool overwrite=false)
TypeConstruction RegTypeInfo (const QString &t) const
QList< TypeConstructionRegisteredTypes () const
 Return list of registered types.

Static Public Member Functions

static const char * Version ()
 Return version info.

Detailed Description

Python-Qt context manager. Helper methods for Qt-Python interaction.

This class is the interface exposed by QPy to client code. Use the provided methods to add QObject-derived type, QObject instances and other types the Python context. PyContext is also used internally by other classes to add QObjects returned by methods or received from signals to the Python context.


Constructor & Destructor Documentation

Destructor: free all QVariant <--> Python converters that are not foreign owned


Member Function Documentation

template<typename T >
void qpy::PyContext::Add ( PyObject *  module,
bool  checkConstructor = true,
const QSet< QString > &  selectedMembers = QSet< QString >(),
const PyMemberNameMapper mm = DefaultMemberNameMapper(),
const char *  className = 0,
const char *  doc = 0 
) [inline]

Templated version of Addtype. QMetaObject is automatically extracted.

Parameters:
modulePython module where type is added
checkConstructorif the method rises an exception in case a constructor is not available; note that when adding pre-created instances through the AddObject method it is not required that the object be constructible from Python
selectedMembersselect the members(properties or method) to make accessible from Python; if not specified all members are exposed
mmoptional member name mapper
classNamespecify class name; if NULL the Qt class name is used
docoptional documentation string
PyTypeObject * qpy::PyContext::AddType ( const QMetaObject *  mo,
PyObject *  module,
bool  checkConstructor = true,
const QSet< QString > &  selectedMembers = QSet< QString >(),
const PyMemberNameMapper mm = DefaultMemberNameMapper(),
const char *  className = 0,
const char *  doc = 0 
)

Add type to Python interpreter; the Qt type is wrapped with a Python class. Instances are created from within Python by explicilty invoking constructors mapped to the actual C++ constructors declared as Q_INVOKABLE.

Parameters:
moMetaObject pointer to the type to add
modulePython module where type is added
checkConstructorif the method rises an exception in case a constructor is not available; note that when adding pre-created instances through the AddObject method it is not required that the object be constructible from Python
selectedMembersselect the members(properties or method) to make accessible from Python; if not specified all members are exposed
mmoptional member name mapper
classNamespecify class name; if NULL the Qt class name is used
docoptional documentation string

Return global functions to be added to Python module. These are the mainly the functions required for accessing the signal-slot binding facilities.

template<typename QArgConstructorT , typename PyArgConstructorT >
bool qpy::PyContext::RegisterType ( const QString &  typeName,
bool  overwrite = false 
) [inline]

Register new types by passing the type of QArgConstructor and PyArgConstructor; this way of registering does not allow to pass actual instances, and does require support for operator new and delete.

template<typename T , typename QArgConstructorT , typename PyArgConstructorT >
bool qpy::PyContext::RegisterType ( const QString &  typeName,
bool  overwrite = false 
) [inline]

Register new types by passing the type of QArgConstructor and PyArgConstructor; this way of registering does not allow to pass actual instances, and does require support for operator new and delete. Also register the

TypeConstruction qpy::PyContext::RegTypeInfo ( const QString &  t) const [inline]

Return information on registered type.

Parameters:
ttype name

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions