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:
committed by
GitHub
parent
b00a4384bf
commit
51987dc1ab
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user