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
Contributor
marcel808
Posts: 27
Registered: ‎09-03-2012
My Device: Blackberry Playbook
My Carrier: None

Open an image in Shared folder using Qt

sorry! another newbie question.

 

Using standard C in my playbook app I can see files in "shared/images" and I can see cover.png is there but if I use that path in Qt, to open the image, I get a fail returned, image not loaded.

What am I doing wrong :smileysad:

thanks

 

QImage myImage;
bool val = myImage.load("shared/videos/cover.png");
// bool always false

 

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 660
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: Open an image in Shared folder using Qt

[ Edited ]

your app has access_shared permissions in it's bar-descriptor, right?

have you tried checking what the returned error is?

 

qDebug() << myImage.error();
qDebug() << myImage.errorString();

 Also, have you tried an absolute path, like "file:///accounts/1000/shared/videos/cover.png"?  It's possible "file:" is required as part of a Qt pathname URI.

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Open an image in Shared folder using Qt

Dangerous to hard code a path like that. Is there not something to obtain the native path of the shared/documents directory like there is in AS3?
Please use plain text.
Contributor
marcel808
Posts: 27
Registered: ‎09-03-2012
My Device: Blackberry Playbook
My Carrier: None

Re: Open an image in Shared folder using Qt

baby steps...I'm stubbling along, all the problems seem to be in the Qt port for Playbook :smileysad:

 

If I try:

 

QImage myImage;
bool val = myImage.load("shared/videos/cover.png");

 then that fails always, if I check the error message it varies from unknown error and unsupported format.

 

But this works fine:

QFile PixmapFile("shared/videos/cover.png");
QByteArray bArray;
QPixmap Pixmap;
bArray = PixmapFile.readAll().toBase64();
Pixmap.loadFromData(bArray.fromBase64(bArray));

 Looks like some methods work ok, others not.

My next challenge is to try and load jpeg files. If I change the file to a jpg, bArray is filled but loadFromData fails (I can't see a way to get an error message from it, just boolean false).

Qt must support jpegs so it muct be the Qt for Playbook so libraries I downloaded, they must be missing jpeg support I think.

thanks

cel

Please use plain text.
Contributor
marcel808
Posts: 27
Registered: ‎09-03-2012
My Device: Blackberry Playbook
My Carrier: None

Re: Open an image in Shared folder using Qt

Got it working finally!

I opened bar-descriptor.xml, Assets tab and added (wherever_your_qt_is)/qt4/plugins/imageformats/libqjpeg.so

I then clicked the Source tab and changed:

type="Qnx/Elf">lib/libqjpeg.so</asset>

to

type="Qnx/Elf">lib/imageformats/libqjpeg.so</asset> 

 

Rebuilt and all works fine now

Please use plain text.