| 806 | } |
| 807 | |
| 808 | Py::Object PythonWrapper::fromQObject(QObject* object, const char* className) |
| 809 | { |
| 810 | if (!object) { |
| 811 | return Py::None(); |
| 812 | } |
| 813 | const char* typeName; |
| 814 | if (className) { |
| 815 | typeName = className; |
| 816 | } |
| 817 | else { |
| 818 | typeName = object->metaObject()->className(); |
| 819 | } |
| 820 | #if defined(HAVE_SHIBOKEN) && defined(HAVE_PYSIDE) |
| 821 | // Access shiboken/PySide via C++ |
| 822 | auto type = getPyTypeObjectForTypeName<QObject>(); |
| 823 | if (type) { |
| 824 | PyObject* pyobj = Shiboken::Object::newObject(type, object, false, false, typeName); |
| 825 | WrapperManager::instance().addQObject(object, pyobj); |
| 826 | return Py::asObject(pyobj); |
| 827 | } |
| 828 | #else |
| 829 | // Access shiboken/PySide via Python |
| 830 | Py::Object obj = qt_wrapInstance<QObject*>(object, typeName, "QtCore"); |
| 831 | if (!obj.isNull()) { |
| 832 | return obj; |
| 833 | } |
| 834 | #endif |
| 835 | throw Py::RuntimeError("Failed to wrap object"); |
| 836 | } |
| 837 | |
| 838 | Py::Object PythonWrapper::fromQWidget(QWidget* widget, const char* className) |
| 839 | { |
no test coverage detected