implement getWrapperName to get class name with shiboken wrapper
This commit is contained in:
parent
541d767335
commit
b16fbcd4ee
|
@ -284,6 +284,22 @@ Py::Object PythonWrapper::fromQWidget(QWidget* widget, const char* className)
|
|||
#endif
|
||||
}
|
||||
|
||||
const char* PythonWrapper::getWrapperName(QObject* obj) const
|
||||
{
|
||||
#if defined (HAVE_SHIBOKEN) && defined(HAVE_PYSIDE)
|
||||
const QMetaObject* meta = obj->metaObject();
|
||||
while (meta) {
|
||||
const char* typeName = meta->className();
|
||||
PyTypeObject* exactType = Shiboken::Conversions::getPythonTypeObject(typeName);
|
||||
if (exactType)
|
||||
return typeName;
|
||||
meta = meta->superClass();
|
||||
}
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool PythonWrapper::loadCoreModule()
|
||||
{
|
||||
#if defined (HAVE_SHIBOKEN2) && (HAVE_PYSIDE2)
|
||||
|
@ -774,7 +790,8 @@ Py::Object UiLoaderPy::load(const Py::Tuple& args)
|
|||
wrap.loadGuiModule();
|
||||
wrap.loadWidgetsModule();
|
||||
|
||||
Py::Object pyWdg = wrap.fromQWidget(widget);
|
||||
const char* typeName = wrap.getWrapperName(widget);
|
||||
Py::Object pyWdg = wrap.fromQWidget(widget, typeName);
|
||||
wrap.createChildrenNameAttributes(*pyWdg, widget);
|
||||
wrap.setParent(*pyWdg, parent);
|
||||
return pyWdg;
|
||||
|
@ -830,7 +847,9 @@ Py::Object UiLoaderPy::createWidget(const Py::Tuple& args)
|
|||
}
|
||||
wrap.loadGuiModule();
|
||||
wrap.loadWidgetsModule();
|
||||
return wrap.fromQWidget(widget);
|
||||
|
||||
const char* typeName = wrap.getWrapperName(widget);
|
||||
return wrap.fromQWidget(widget, typeName);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------
|
||||
|
|
|
@ -50,6 +50,7 @@ public:
|
|||
bool toCString(const Py::Object&, std::string&);
|
||||
QObject* toQObject(const Py::Object&);
|
||||
Py::Object fromQWidget(QWidget*, const char* className=0);
|
||||
const char* getWrapperName(QObject*) const;
|
||||
/*!
|
||||
Create a Python wrapper for the icon. The icon must be created on the heap
|
||||
and the Python wrapper takes ownership of it.
|
||||
|
|
Loading…
Reference in New Issue
Block a user