11-27-2012 10:55 AM
Purpose:
Want to get screen height and width for .qml.
Problme:
When I try to get screen width, .qml code shows error.
or
When I try to use .qml, screen properties shows error.
code:
using namespace bb::cascades;
using namespace bb::device;??
int main(int argc, char **argv)
{
// this is where the server is started etc
Application app(argc, argv);
// localization support
QTranslator translator;
QString locale_string = QLocale().name();
QString filename =****
if (translator.load(filename, "app/native/qm")) {
app.installTranslator( &translator );
}
// Load the UI description from main.qml
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(&a
DisplayInfo display;
int width = display.pixelSize().width();
int height = display.pixelSize().height();
Does anyone know how to use device and cascade in one project.
Thanks your attention.
Solved! Go to Solution.
11-27-2012 11:17 AM
Hi
I'm not clear exactly where you are seeing errors.
However the following code works for me:
// Default empty project template
#include "Test.hpp"
#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>
#include <bb/device/DisplayInfo.hpp>
using namespace bb::cascades;
using namespace bb::device;
Test::Test(bb::cascades::Application *app)
: QObject(app)
{
DisplayInfo display;
qDebug() << "XXXX display id is " << display.displayId();
qDebug() << "XXXX display name is " << display.displayName();
qDebug() << "XXXX display size is " << display.pixelSize().width() << ", " << display.pixelSize().height();
// create scene document from main.qml asset
// set parent to created document to ensure it exists for the whole application lifetime
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(th is);
// create root object for the UI
AbstractPane *root = qml->createRootObject<AbstractPane>();
// set created root object as a scene
app->setScene(root);
}
Make sure you add the following line to your project's .pro file
LIBS += -lbbdevice
per the documentation: http://developer/cascades/reference
Hope this helps!
11-27-2012 11:28 AM
LIBS += -lbbdevice is my issue.
After I add the LIBS += -lbbdevice under HEADERS += ../src/*.hpp ../src/*.h for the .pro file.
No warning comes out.
Thank you a lot, Solved it.