thanks. Can you give some references where you have found the information. I tried it. but the typeinfo doesn't match the subclassname:
I implemented a little demo application:
Code: Select all
from PySide2 import QtWidgets
class MyWidget(QtWidgets.QWidget):
def event(self, e):
print type(e)
return False
w=MyWidget()
w.show()
When opening qwidget_wrapper.cpp then there is the overridden event() method of the Python wrapper which invokes the methods of the Pythpn class MyWidget
Code: Select all
bool QWidgetWrapper::event(QEvent * arg__1)
{
Shiboken::GilState gil;
if (PyErr_Occurred())
return ((bool)0);
Shiboken::AutoDecRef pyOverride(Shiboken::BindingManager::instance().getOverride(this, "event"));
if (pyOverride.isNull()) {
gil.release();
return this->::QWidget::event(arg__1);
}
Shiboken::AutoDecRef pyArgs(Py_BuildValue("(N)",
Shiboken::Conversions::pointerToPython((SbkObjectType*)SbkPySide2_QtCoreTypes[SBK_QEVENT_IDX], arg__1)
));
...
}
When stepping through the code then the SbkConverter's pointerToPython function is this:
Code: Select all
// C++ to Python pointer conversion - tries to find the Python wrapper for the C++ object (keeps object identity).
static PyObject* QEvent_PTR_CppToPython_QEvent(const void* cppIn) {
PyObject* pyOut = (PyObject*)Shiboken::BindingManager::instance().retrieveWrapper(cppIn);
if (pyOut) {
Py_INCREF(pyOut);
return pyOut;
}
const char* typeName = typeid(*((::QEvent*)cppIn)).name();
return Shiboken::Object::newObject(&Sbk_QEvent_Type, const_cast<void*>(cppIn), false, false, typeName);
}
If e.g. a mouse move is performed then for VS compilers the value of typeid().name() is
class QMoveEvent. In the further handling there is no code that tries to get an unmangled name, i.e. removing the prefix
class.