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

Reply
Regular Contributor
Posts: 93
Registered: ‎08-20-2013
My Device: BB 10 -BlackBerry Z10
My Carrier: BlackBerry

Re: Getting device info

[ Edited ]

.cpp --

 

 

DeviceInfo::DeviceInfo(bb::cascades::Application *app)
: QObject(app)
{
    // 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);

    info = new HardwareInfo(this);


}

  

	void DeviceInfo::get()
{
imei = info->imei(); device_name = info->deviceName(); model_number = info->modelNumber(); serial_number = info->serialNumber(); qDebug() << "IMEI: " << imei << endl << "Device name: " << device_name << endl <<"Serial Number: " << device_name << endl;
}

 

 

Developer
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: Getting device info

[ Edited ]
info = new HardwareInfo(this);

info is a pointer so you need to use Indirection operator ->

So you've got bugs here:

imei  = info.imei();
model_number = info.modelNumber();
serial_number = info.serialNumber();

Be carefull

Eclipse IntelliSense is very slow Smiley Wink

 

Tip: Don't forget deallocate memory in DeviceInfo destructor with delete operator

void DeviceInfo::~DeviceInfo(){
    delete info;
}

 



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Regular Contributor
Posts: 93
Registered: ‎08-20-2013
My Device: BB 10 -BlackBerry Z10
My Carrier: BlackBerry

Re: Getting device info

Sorry I made a mistake while replying you. I had used -> operator for calling those functions .

Highlighted
Developer
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: Getting device info

And still doesn't work  ? Must work. Again, try Clean the whole project and Build it again. Somewhere in the code you have error, check the code.



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog