Fixups with Qt6 enums (#13611)

* Python PySide enums to C++ converter

* Python IntFlags to C++ int in getStandardButtons

* Remove int conversion in mods Python sources
This commit is contained in:
Martin Rodriguez Reboredo
2024-05-06 13:02:18 -03:00
committed by GitHub
parent b00a4384bf
commit 51987dc1ab
27 changed files with 64 additions and 52 deletions

View File

@@ -583,6 +583,36 @@ QObject* PythonWrapper::toQObject(const Py::Object& pyobject)
return qt_getCppType<QObject>(pyobject.ptr());
}
qsizetype PythonWrapper::toEnum(PyObject* pyPtr)
{
#if defined (HAVE_SHIBOKEN) && defined(HAVE_PYSIDE)
return Shiboken::Enum::getValue(pyPtr);
#else
return toEnum(Py::Object(pyPtr);
#endif
}
qsizetype PythonWrapper::toEnum(const Py::Object& pyobject)
{
#if defined (HAVE_SHIBOKEN) && defined(HAVE_PYSIDE)
return toEnum(pyobject.ptr());
#else
try {
Py::Int ret;
if (pyobject.hasAttr(std::string("value"))) {
ret = Py::Int(pyobject.getAttr(std::string("value")));
} else {
ret = Py::Int(pyobject);
}
return (qsizetype)ret;
}
catch (Py::Exception&) {
Base::PyException e; // extract the Python error text
e.ReportException();
}
#endif
}
QGraphicsItem* PythonWrapper::toQGraphicsItem(PyObject* pyPtr)
{
return qt_getCppType<QGraphicsItem>(pyPtr);