[PySide] Support for namespaces in shiboken2

icfwm at gmx.net icfwm at gmx.net
Wed Jan 15 19:47:19 CET 2020


I think you can use the namespace-type for this
(https://doc.qt.io/qtforpython/shiboken2/typesystem_specifying_types.html#namespace-type).
Not sure if the using statement in bindings.h is any good.

<!--?xml version="1.0"?-->
<typesystem package="ptest">
    <namespace-type name="MyLibrary">
        <namespace-type name="Core">
            <object-type name="MyClass" />
        </namespace-type>
    </namespace-type>
</typesystem>

On the python side, these namespaces are then generated as classes in
the module.

On 15.01.20 19:35, info at mycontent.gr wrote:
> Dear all,
>
> I have a question regarding support for namespaces in shiboken2:
>
> Is it possible to create bindings for a library whose classes are
> defined within a namespace, and if yes, what is the correct way of
> indicating this in the bindings.h / bindings.xml files?
>
> I have tried the following (minimal example) :
>
> namespace MyLibrary {
>     namespace Core {
>         class MYLIBRARY_SHARED_EXPORT MyClass {
>             ...
>         };
>     }
> }
>
> and added "using MyLibrary::Core;" at the end of bindings.h. However,
> shiboken2 gives the following warning:
>
> qt.shiboken: (bindings) type 'MyClass' is specified in typesystem, but
> not defined. This could potentially lead to compilation errors.
>
> and does not generate a myclass_wrapper.cpp file; consequently the
> build fails. When I remove the namespaces, everything works fine.
>
> Thank you for your help
>
> Kind regards,
>
> George Christodoulides
>
>
>
> _______________________________________________
> PySide mailing list
> PySide at qt-project.org
> https://lists.qt-project.org/listinfo/pyside




More information about the PySide mailing list