[Gui]add support for QGraphicsObject to PythonWrapper
This commit is contained in:
committed by
WandererFan
parent
d63b723d02
commit
aa979441d7
@@ -26,6 +26,8 @@
|
||||
# include <QDir>
|
||||
# include <QIcon>
|
||||
# include <QWidget>
|
||||
# include <QGraphicsItem>
|
||||
# include <QGraphicsObject>
|
||||
#endif
|
||||
|
||||
#include <QMetaType>
|
||||
@@ -368,7 +370,7 @@ QObject* PythonWrapper::toQObject(const Py::Object& pyobject)
|
||||
QGraphicsItem* PythonWrapper::toQGraphicsItem(PyObject* pyPtr)
|
||||
{
|
||||
#if defined (HAVE_SHIBOKEN) && defined(HAVE_PYSIDE)
|
||||
PyTypeObject* type = getPyTypeObjectForTypeName<QObject>();
|
||||
PyTypeObject* type = getPyTypeObjectForTypeName<QGraphicsItem>();
|
||||
if (type) {
|
||||
if (Shiboken::Object::checkType(pyPtr)) {
|
||||
SbkObject* sbkobject = reinterpret_cast<SbkObject*>(pyPtr);
|
||||
@@ -385,6 +387,26 @@ QGraphicsItem* PythonWrapper::toQGraphicsItem(PyObject* pyPtr)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QGraphicsObject* PythonWrapper::toQGraphicsObject(PyObject* pyPtr)
|
||||
{
|
||||
#if defined (HAVE_SHIBOKEN) && defined(HAVE_PYSIDE)
|
||||
PyTypeObject* type = getPyTypeObjectForTypeName<QGraphicsObject>();
|
||||
if (type) {
|
||||
if (Shiboken::Object::checkType(pyPtr)) {
|
||||
SbkObject* sbkobject = reinterpret_cast<SbkObject*>(pyPtr);
|
||||
void* cppobject = Shiboken::Object::cppPointer(sbkobject, type);
|
||||
return reinterpret_cast<QGraphicsObject*>(cppobject);
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Access shiboken2/PySide2 via Python
|
||||
//
|
||||
void* ptr = qt_getCppPointer(Py::asObject(pyPtr), "shiboken2", "getCppPointer");
|
||||
return reinterpret_cast<QGraphicsObject*>(ptr);
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Py::Object PythonWrapper::fromQIcon(const QIcon* icon)
|
||||
{
|
||||
#if defined (HAVE_SHIBOKEN) && defined(HAVE_PYSIDE)
|
||||
|
||||
Reference in New Issue
Block a user