Normally, Python containers such as
dict are passed when
calling C++ functions taking a corresponding C++ container (see
This means that for each call, the entire Python container is converted to a C++ container, which can be inefficient when for example creating plots from lists of points.
To work around this, special opaque containers can generated which wrap an
underlying C++ container directly (currently implemented for
They implement the sequence protocol and can be passed to the function
instead of a Python list. Manipulations like adding or removing elements
can applied directly to them using the C++ container functions.
This is achieved by specifying the name and the instantiated type
opaque-containers attribute of container-type.
A second use case are public fields of container types. In the normal case, they are converted to Python containers on read access. By a field modification, (see modify-field), it is possible to obtain an opaque container which avoids the conversion and allows for direct modification of elements.
The table below lists the functions supported for opaque sequence containers
besides the sequence protocol (element access via index and
the STL and the Qt naming convention (which resembles Python’s) are supported:
Appends value to the sequence.
Prepends value to the sequence.
Clears the sequence.
Removes the last element.
Removes the first element.
© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.