In main.cpp after creating your QmlDocument, qml->setContextProperty("yourshortcut", object);
void xxx::invokeEmail(){
InvokeManager invokeManager;
InvokeRequest request;
request.setTarget("sys.pim.uib.email.hybridcomposer");
request.setAction("bb.action.COMPOSE");
request.setMimeType("message/rfc822");
InvokeTargetReply *reply = invokeManager.invoke(request);
if(reply) {
reply->setParent(this);
QObject::connect(reply, SIGNAL(finished()),this, SLOT(onInvokeResult()));
_invokeTargetReply = reply;
}
delete reply;
}
void xxx::onInvokeResult()
{
// Check for errors
switch(_invokeTargetReply->error()) {
// Invocation could not find the target
// did we use the right target ID?
case InvokeReplyError::NoTarget: {
qDebug() << "invokeFinished(): Error: no target" << endl;
break;
}
// There was a problem with the invoke request
// did we set all the values correctly?
case InvokeReplyError::BadRequest: {
qDebug() << "invokeFinished(): Error: bad request" << endl;
break;
}
// Something went completely
// wrong inside the invocation request
// Find an alternate route :(
case InvokeReplyError::Internal: {
qDebug() << "invokeFinished(): Error: internal" << endl;
break;
}
//Message received if the invoke request is successful
default:
qDebug() << "invokeFinished(): Invoke Succeeded" << endl;
break;
}
// A little house keeping never hurts...
delete _invokeTargetReply;
}
Then in QML call the C++ function invokeEmail using the shortcut you created with the context property. I use this to invoke the email card