I want to open server page url in n950's default webbrowser using Qt html5 template.
-
I have html pages in my Qt html5 application. on Button click i want to open n950 default browser. just like as we do in c++ code.
QDesktopServices::openUrl('my url'); -
@DanSiddiqui: is this post a "restart" of this previous: http://developer.qt.nokia.com/forums/viewthread/9787/ ?
What is the problem exactly ?
-
No, its an another issue, In my html page when i add
@
<a href='My server url'></a>
@
it redirect my Qt application (html5) to that (url) page but i want to open this url to Default Browser. -
Well, as I know, the only way is to intercept the links and for every link you have you should call a open url using the external browser.
You can intercept your link with
@
onClicked: Qt.openUrlExternally(delegate.newslink)
@
Or use a bit more complex mechanism with a wrapper connected to the onLinkActivated: state. -
Thanks Alicemirror ::::::::::::
As i said i am developing an html5 app so in my application contain html pages. i put a button on this
page and call a function OpenUrl on its click events;
@
function OpenUrl(){
Qt.openUrlExternally('http://google.com');
}
@
but its not working: -
It si corrct, I think that you should use the state of onLinkActivated: that when happens if you click on a link on the html page this link is not automatically forwarded inside the pageview itself but is connected to the function.
To have a good example of a openUrl() function that works for sure and includes some error management, you can clone the project http://projects.nokia.com/rchobbystream Despite that this project manages links inside the elements of a rss feed the principle is the same and you find all the elements that you need to be applied in your program.
See che sources that are related to TweetComponent.qml. Here is the lnk manager function:
@
/* handleLink(link)
Manages the links in the twitter message: if it is a usr (http protocol)
when clicked the link is opened in the default browser.
*/
function handleLink(link){
if(link.slice(0,3) == 'app') {
screen.setUser(link.slice(7));
}
else if(link.slice(0,4) == 'http') {
Qt.openUrlExternally(link);
}
}
@
Then see also the sources in the pages related to Web. In biref the solution that I had adopted to show ad banners on top of the page:
Every banner is a mini WebView. In the application there are local html pages that - see them - opens only the banner. Thus, when you click over this link (that is the image, as is the banner or the entire micro page) your click is intercepted and sent to the external browser.Hope it will help.
Is this application open source? I am curious on how do you are managing some solutions. -
I think Alicemirror, you are not getting my point, this above exmaple is using .qml file like
http://doc.qt.nokia.com/latest/demos-declarative-twitter-twittercore-fatdelegate-qml.html
but i have simple html page open in my main.cpp file.
@
QApplication app(argc, argv);
Html5ApplicationViewer viewer;
viewer.setOrientation(Html5ApplicationViewer::ScreenOrientationAuto);
viewer.showExpanded();
viewer.loadFile(QLatin1String("html/index.html"));
return app.exec();
@
In this (html) page i want to redirect (server url) to the mobile's (n950)
default browser.