[PySide] Read only member

Mike Krus mike.krus at kdab.com
Sat May 11 20:58:27 CEST 2019


I’m trying to use PySide/Shiboken2 with a new Qt based module.
I have one class that has a read only, constant member variable.
It has an accessor but no setter. It is NOT a Q_PROPERTY though.

class  AbstractFoo : public QObject
    enum Type {
        Custom = 0


    Type type() const;

    explicit AbstractFoo(QObject *parent = nullptr, Type = Custom);
    const Type m_type;

I’m getting an issue when compiling the generated wrapper class:

foo_wrapper.h:33:142: error: cannot assign to non-static data member 'm_type' with
      const-qualified type 'const Foo::Type'
    inline void protected_m_type_setter(const Foo::Type value) { Foo::m_type = value; }

Obviously this doesn’t compile since m_type is constant.

Any tag I add to the bindings.xml file to tell the generator to not add a setter?



Mike Krus | mike.krus at kdab.com | Senior Software Engineer
KDAB (UK) Ltd., a KDAB Group company
Tel: UK Office +44 1625 809908   Mobile +44 7833 491941
KDAB - The Qt Experts, C++, OpenGL Experts

More information about the PySide mailing list