Dear all,
I’m playing with QML trying to use it in a non-GUI program. It works very well :-)
But now, I would to report javascript errors to the users and I did not find a way to do it.
This is the way I’m using QML.
The user write a qml script that contains a root element defined by me with some javascript function inside, that’s an example:
Experiment {
function initGeneration( id ) {
world.addSphere( "target", 0.02 );
target.setMass( 0.0 );
target.setMaterial( "targetMaterial" );
target.setMatrix( utils.identityMatrix() );
logger.info( "PureReachAbs - Main Initialization done" );
}
}
In the example above, “world”, “target”, “utils” and “logger” are all global object defined by C++ application using QDeclarativeContext::setContextProperty().
I create the Experiment instance from the C++ application using the QDeclarativeComponet::create() method.
If there is an syntax error in the QML script the create method reports it correctly … but it cannot check if the global variables exist or not.
So, supposing to change the following line:
logger.info( "PureReachAbs - Main Initialization done" );
with a one with a “logger” written wrongly:
loggre.info( "PureReachAbs - Main Initialization done" );
The QDeclarativeContext::create() do not report any syntax error. And that’s fine.
But when later, I use from C++ application the QMetaObject::invokeMethod in order to call the javascript function “initGeneration” with the wrong line, what it happens is that it is not executed and no errors is reported back.
So, I cannot display to the user a error saying something like: “loggre is undefined”.
How can I do that ?? There is a way to report these errors to the user ??
Thank you,
Gianluca.
↧