From 4f113db76f54baeb8e11ccf5eb4a758ef17b691c Mon Sep 17 00:00:00 2001 From: Uwe Siems Date: Wed, 20 Dec 2023 14:42:49 +0100 Subject: [PATCH] Add enum values to the enum type object itself in any case... ...not just when it is a enum class in C++. It seems PySide does this too. --- src/PythonQtClassInfo.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/PythonQtClassInfo.cpp b/src/PythonQtClassInfo.cpp index 922658ecb..1f1acf78b 100644 --- a/src/PythonQtClassInfo.cpp +++ b/src/PythonQtClassInfo.cpp @@ -879,17 +879,13 @@ void PythonQtClassInfo::createEnumWrappers(const QMetaObject* meta) QMetaEnum e = meta->enumerator(i); PythonQtObjectPtr p; p.setNewRef(PythonQtPrivate::createNewPythonQtEnumWrapper(e.name(), _pythonQtClassWrapper)); -#if QT_VERSION > 0x050800 - if (e.isScoped()) { - // add enum values to the enum type itself, in case enum value names are so generic - // that they are not unique - for (int j = 0; j < e.keyCount(); j++) { - PythonQtObjectPtr enumValuePtr; - enumValuePtr.setNewRef(PythonQtPrivate::createEnumValueInstance(p.object(), e.value(j))); - p.addVariable(escapeReservedNames(e.key(j)), QVariant::fromValue(enumValuePtr)); - } + // add enum values to the enum type itself, in case enum value names are so generic + // that they are not unique + for (int j = 0; j < e.keyCount(); j++) { + PythonQtObjectPtr enumValuePtr; + enumValuePtr.setNewRef(PythonQtPrivate::createEnumValueInstance(p.object(), e.value(j))); + p.addVariable(escapeReservedNames(e.key(j)), QVariant::fromValue(enumValuePtr)); } -#endif _enumWrappers.append(p); } }