12-03-2012 08:48 AM
Sorry if you saw this in the other forum, I'm re-posting because I just found this sub-forum and it seems a better fit.
I have a ListView and I'm trying to invoke the browser from onTriggered. I want to create an Invocation with an InvokeQuery that has a uri based the user's list selection. I tried this:
onTriggered: {
var selectedItem = dataModel.data(indexPath);
invokeBrowser.query.uri = selectedItem.link;
invokeBrowser.trigger("bb.action.OPEN");
}
attachedObjects: [
Invocation {
id: invokeBrowser
query: InvokeQuery {
uri: ""
}
}
]
But I just get: InvokeQuery: trying to set sealed property uri
What is the right way to do this from QML/JavaScript?
Solved! Go to Solution.
12-03-2012 12:09 PM
I dont know if it has changed in Beta4 but in Beta3 it is not possible to change the InvokeQuery.uri dynamically. Once created this value it is read only - unfortunally.
Instead you can call a c++ function to do it.
I use:
void MyApp::invokeBrowser(const QString &uri) {
InvokeRequest request;
request.setAction("bb.action.OPEN");
request.setMimeType("text/html");
request.setUri(uri);
const InvokeReply *reply = m_invokeManager->invoke(request);
}UPDATE:
I just read, that it changed in Beta4.
You can change the Query but you need to call updateQuery() then. I will test it tomorrow.
look inside the documentation.
12-03-2012 12:25 PM - edited 12-03-2012 12:26 PM
Is there a better way than updating the query? Can I make a new Invocation object on the fly?
I can build a C++ wrapper, but I'd rather do it all from QML+JavaScript if possible.
12-03-2012 12:40 PM
Following the documentation this code should work, but it does not:
InvokeActionItem {
id: invokeBrowser
title: "Browser"
imageSource: "asset:///images/browser_action.png"
ActionBar.placement: ActionBarPlacement.OnBar
onTriggered: {
query.uri = "http://myNewUri.com"
}
query {
uri: ""
mimeType: "text/html"
invokeActionId: "bb.action.OPEN"
onQueryChanged: invokeBrowser.query.updateQuery()
}
}The onQueryChanged Signal is unknown...
12-03-2012 12:42 PM
That's still updating the query.
I'll try getting Beta4 and using an update-the-query method, then.
12-08-2012 03:43 PM
Yeah, this does not work, and trying to invoke updateQuery directly fails still under BETA4 (gives an error).
12-22-2012 01:46 PM
I am having an issue with updateQuery such as yours, was this resolved? I am using the gold version.
12-22-2012 02:06 PM
If it still doesn't work in gold, then they're probably not going to fix it. I'm considering it a bug in the documentation for now.
I haven't yet, but am considering writing a shim in C++ that just gets included into my projects so that I can access a way to do invocations from QML.
12-22-2012 02:16 PM
I'll look into doing the same, it is unfortunate that some of the documentation for this is slightly inaccurate.
12-22-2012 11:18 PM
This works for invoking the browser in a dynamic fashion ![]()
InvokeActionItem {
id: invokeB
title: "Open in Browser"
imageSource: "images/globe.png"
query {
uri: webView.url
mimeType: "text/html"
invokeActionId: "bb.action.OPEN"
onQueryChanged: invokeB.query.updateQuery()
}
}In the code above I am using the InvokeActionItem to open the current webView url in the external browser.