Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Super Contributor
Posts: 253
Registered: ‎08-19-2010
My Device: BB10, Playbook, 9900, 9800, 9700, 9550, 9530, 9500, 8700.
My Carrier: TT
Accepted Solution

How to combine bb::cascades and bb::device

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(&app);

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.

 

-Fight with BB10
Retired
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: How to combine bb::cascades and bb::device

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(this);

    // 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/bb__device__displayinfo.html

 

Hope this helps!

 

 

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Super Contributor
Posts: 253
Registered: ‎08-19-2010
My Device: BB10, Playbook, 9900, 9800, 9700, 9550, 9530, 9500, 8700.
My Carrier: TT

Re: How to combine bb::cascades and bb::device

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.

 

 

 

 

-Fight with BB10