You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Using enum elements from C++ Qt Object in python #71
I think you may need to provide a self-defined wrapper class for your own class.
And define the enums in the wrapper class.
My test code is below:
wrapper code:
classTestCppObj {
public:///... other functions
};
classTestCppObjWrapper : publicQObject {
Q_OBJECTpublic:enum TestEnum { A, B, C }; /// define enums here!Q_ENUMS(TestEnum)
public slots:
///... other slots for this type
Defining a custom wrapper class for a QObject-derived class should not be necessary if all required methods already are slots, since then PythonQt can determine all necessary information from the data in QMetaType. The same normally goes for enum types that are registered with Q_ENUM.
This issue is quite old, so I don't know if this is still relevant. Usually the enum type and the values should be available, since they are derived from the QMetaType, so I have no explanation for this behavior.
Activity
ChenxiLiu-code commentedon Apr 29, 2025
I think you may need to provide a self-defined wrapper class for your own class.
And define the enums in the wrapper class.
My test code is below:
wrapper code:
register code:
python code:
output:
usiems commentedon Apr 30, 2025
Defining a custom wrapper class for a QObject-derived class should not be necessary if all required methods already are slots, since then PythonQt can determine all necessary information from the data in QMetaType. The same normally goes for enum types that are registered with Q_ENUM.
This issue is quite old, so I don't know if this is still relevant. Usually the enum type and the values should be available, since they are derived from the QMetaType, so I have no explanation for this behavior.