Skip to content

Commit

Permalink
Add enum values to the enum type object itself in any case...
Browse files Browse the repository at this point in the history
...not just when it is a enum class in C++. It seems PySide does this too.
  • Loading branch information
usiems committed Dec 20, 2023
1 parent e9197ec commit 4f113db
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/PythonQtClassInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 4f113db

Please sign in to comment.