Created
September 19, 2012 22:44
-
-
Save 40/3752815 to your computer and use it in GitHub Desktop.
Source Code for Launching BB10 Browser from Cascades App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "app.hpp" | |
#include <bb/cascades/Application> | |
#include <bb/cascades/QmlDocument> | |
#include <bb/cascades/AbstractPane> | |
#include <bps/navigator.h> | |
using namespace bb::cascades; | |
App::App() | |
{ | |
QmlDocument *qml = QmlDocument::create("main.qml"); | |
//-- setContextProperty expose C++ object in QML as an variable | |
qml->setContextProperty("app", this); | |
AbstractPane *root = qml->createRootNode<AbstractPane>(); | |
Application::setScene(root); | |
} | |
App::launchBrowser(QString url) | |
{ | |
navigator_invoke(url.toStdString().c_str(), 0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef APP_H | |
#define APP_H | |
#include <QObject> | |
#include <bps/navigator.h> | |
/*! | |
* @brief Application GUI object | |
*/ | |
class App : public QObject | |
{ | |
Q_OBJECT | |
public: | |
App(); | |
Q_INVOKABLE void launchBrowser(QString url); | |
}; | |
#endif // ifndef APP_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bb.cascades 1.0 | |
//-- create one page with a label and text | |
Page { | |
content: Container{ | |
Button{ | |
id: launchButton | |
text: "Launch Browser" | |
onClicked: { | |
app.launchBrowser("http://www.blackberry.com"); | |
} | |
} | |
} | |
} |
Yes, this code snippet does work.
Thanks.
You would need an bb::cascades::Invocation
object in your App for this to work. This is most likely used in the bps/navigator.h
file which is not shown here. The correct way to do this would be
#include <bb/cascades/Invocation>
#include <bb/csacades/InvokeQuery>
bb::cascades::Invocation *m_invoker;
m_invoker = bb::cascades::Invocation::create(
bb::cascades::InvokeQuery()
.loc("http://google.com")
.mimetype("text/plain")
.parent(this));
connect(m_invoker, SIGNAL(armed()), this, SLOT(onInvokerArmed()));
void ThisClass::onInvokerArmed() {
m_invoker->trigger("bb.action.OPEN");
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi i was trying with same example but getting erros in blackberry 10 cascades
Request you to help me on this
Thank you