What I do is to emit a signal when an error occurs. The net effect is essentially the same as throwing and catching an exception.
In QML I do things like:
Connections {
target: myCppObject
onFileNotFoundError: messageBox.show("Could not find file")
}
messageBox is a QtQuick item that can be made visible through a show() method. It may be just a Rectangle with a Text and an OK button for example.
I’m not aware of any way to throw an exception in C++ and have this somehow converted to a javascript exception in QML.
↧