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
Super Contributor
Meghasanghvi
Posts: 306
Registered: ‎08-10-2010
My Device: Not Specified
Accepted Solution

Image load from filesystem

Hi,

 

I want to load the image from particular location of my file system but image is not loaded and i am not able to see the image on siumulator.

Below is my code for the same.



Image image = Image(QUrl("D:\Megha\linux.png"));

 

ImageView* pMyImageView = ImageView::create();
pMyImageView->setImage(image);


Page *page = new Page();
page->setContent(pMyImageView);

Application::setScene(page);

 

But no image is displyed

BlackBerry Development Advisor (Retired)
smacmartin
Posts: 499
Registered: ‎05-07-2012
My Device: developer

Re: Image load from filesystem

You hardcoded the path to D:  Presumably this file is not in that location on the simulator or the device.

 

See the documentation in https://developer.blackberry.com/cascades/reference/bb__cascades__image.html for setting this relative or using your assets.

 

Image inherits from Resource, so has isNull().  QUrl has both isValid() and isEmpty().

You should add some defensive code.

 

Stuart

BlackBerry Development Advisor (Retired)
smacmartin
Posts: 499
Registered: ‎05-07-2012
My Device: developer

Re: Image load from filesystem

Did you get past your issue?

If so, please close the thread by accepting a solution.

If not, where do you now need help?

 

Stuart