main.cpp Example File
batterysample/src/main.cpp
#include <bb/cascades/AbstractPane>
#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/device/BatteryInfo>
#include <QtCore/QLocale>
#include <QtCore/QTranslator>
using namespace bb::cascades;
using namespace bb::device;
Q_DECL_EXPORT int main(int argc, char **argv)
{
qmlRegisterUncreatableType<bb::device::BatteryChargingState>("bb.device", 1, 0, "BatteryChargingState", "");
Application app(argc, argv);
QTranslator translator;
const QString locale_string = QLocale().name();
const QString filename = QString("batterysample_%1").arg(locale_string);
if (translator.load(filename, "app/native/qm")) {
app.installTranslator(&translator);
}
BatteryInfo batteryInfo;
QmlDocument *qml = QmlDocument::create("asset:///main.qml");
qml->setContextProperty("_battery", &batteryInfo);
AbstractPane *appPage = qml->createRootObject<AbstractPane>();
Application::instance()->setScene(appPage);
return Application::exec();
}