Gui: support of wrapping QImage

This commit is contained in:
wmayer
2023-08-03 00:04:45 +02:00
committed by wwmayer
parent 205c0e7345
commit b202eb2f6b
2 changed files with 35 additions and 1 deletions

View File

@@ -583,9 +583,39 @@ QGraphicsObject* PythonWrapper::toQGraphicsObject(PyObject* pyPtr)
QGraphicsObject* PythonWrapper::toQGraphicsObject(const Py::Object& pyobject)
{
return toQGraphicsObject(pyobject.ptr());
return toQGraphicsObject(pyobject.ptr());
}
Py::Object PythonWrapper::fromQImage(const QImage& img)
{
#if defined (HAVE_SHIBOKEN) && defined(HAVE_PYSIDE)
#if defined (HAVE_SHIBOKEN2)
PyObject* pyobj = Shiboken::Conversions::copyToPython(reinterpret_cast<SbkObjectType*>(getPyTypeObjectForTypeName<QImage>()),
const_cast<QImage*>(&img));
#else
PyObject* pyobj = Shiboken::Conversions::copyToPython(getPyTypeObjectForTypeName<QImage>(),
const_cast<QImage*>(&img));
#endif
if (pyobj) {
return Py::asObject(pyobj);
}
#else
// Access shiboken/PySide via Python
//
return qt_wrapInstance<const QImage*>(&img, "QImage", shiboken, PySide + ".QtGui", "wrapInstance");
#endif
throw Py::RuntimeError("Failed to wrap icon");
}
QImage *PythonWrapper::toQImage(PyObject *pyobj)
{
#if defined (HAVE_SHIBOKEN) && defined(HAVE_PYSIDE)
return qt_getCppType<QImage>(pyobj);
#else
Q_UNUSED(pyobj);
#endif
return nullptr;
}
Py::Object PythonWrapper::fromQIcon(const QIcon* icon)
{