An important feature of PyQt5 (and SIP generated modules in general) is the ability for other extension modules to build on top of it. QScintilla is such an example.
PyQt5 provides an extension API that can be used by other modules. This has the advantage of sharing code and also enforcing consistent behaviour. Part of the API is accessable from Python and part from C++.
The Python part of the API is accessible via the QtCore module and is typically used by an extension module’s equivalent of PyQt5’s configure.py.
The API consists of PyQt5.QtCore.PYQT_CONFIGURATION which is a dict that describes how PyQt5 was configured. At the moment it contains a single value called sip_flags which is a string containing the -t and -x flags that were passed to the sip executable by configure.py. Other extension modules must use the same flags in their configuration.
This information is also provided by SIP v4’s sipconfig module. However this module will not be implemented by SIP v5.
The C++ API is a set of functions. The addresses of each function is obtained by calling SIP’s sipImportSymbol() function with the name of the function required.
Several of the functions are provided as a replacement for SIP v4 features (i.e. SIP_ANYSLOT, SIP_QOBJECT, SIP_RXOBJ_CON, SIP_RXOBJ_DIS, SIP_SIGNAL, SIP_SLOT, SIP_SLOT_CON and SIP_SLOT_DIS) that will not be supported by SIP v5.
The functions exported by PyQt5 are as follows:
Convert a Python list to a standard C array of command line arguments and an argument count.
Parameters: |
|
---|---|
Returns: | an array of pointers to the arguments on the heap. |
Convert a QVariant to a Python object according to an optional Python type.
Parameters: |
|
---|---|
Returns: | the converted value. If it is 0 then a Python exception will have been raised. |
Get the receiver object and slot signature to allow a signal to be connected to an optional transmitter.
Parameters: |
|
---|---|
Returns: | the error state. If this is sipErrorFail then a Python exception will have been raised. |
Get the transmitter object and signal signature from a bound signal.
Parameters: |
|
---|---|
Returns: | the error state. If this is sipErrorFail then a Python exception will have been raised. |
Get the receiver object and slot signature from a callable decorated with pyqtSlot().
Parameters: |
|
---|---|
Returns: | the error state. If this is sipErrorFail then a Python exception will have been raised. |
Get the signature string for a bound or unbound signal. If the signal is bound then it must be bound to the given transmitter.
Parameters: |
|
---|---|
Returns: | the error state. If this is sipErrorFail then a Python exception will have been raised. |
Get the sender of a signal to the current slot proxy. This is only intended to be used by the sender() %MethodCode.
Returns: | the QObject sender. |
---|
Register a convertor function that converts a QVariant value to a Python object.
Parameters convertor: | |
---|---|
is the convertor function. This takes two arguments. The first argument is the QVariant value to be converted. The second argument is updated with a reference to the result of the conversion and it will be 0, and a Python exception raised, if there was an error. The convertor will return true if the value was handled so that no other convertor will be tried. |
Update a Python list from a standard C array of command line arguments and an argument count. This is used in conjunction with pyqt5_from_argv_list() to handle the updating of argument lists after calling constructors of classes such as QCoreApplication.
Parameters: |
|
---|