C++-to-QML error handling
Unsolved
QML and Qt Quick
-
Hello!
I have some questions regarding topic:
- Is there a common customization point, similar to QCoreApplication::notify, which would allow to handle/transform exceptions flying out of native code called by QML?
notify
allowed us to nicely handle all unexpected errors in our previous QWidgets-based project. Sadly, QML engine code seems to be not exception-neutral and crashes miserably if anything "flies" through it. - Is there a way to obtain QML engine pointer from Q_INVOKABLE method which was called from QML, but its owning object was not created by QML?
I've skimmed documentation, sources and Global exception handling with c++/QML topic regarding possible ways to properly handle errors which occur in QML+native codebase. Unfortunately it seems that error handling capabilities and overall integration between C++ and QML is rather limited, basically down to manual error codes. The closest one would have been
QQmlObjectOrGadget::metacall
- if I could override it globally somehow, augment with try-catch and transform caught exception intoengine->throwError
+return
.Thanks
- Is there a common customization point, similar to QCoreApplication::notify, which would allow to handle/transform exceptions flying out of native code called by QML?