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
Developer
Posts: 126
Registered: ‎06-25-2013
My Device: Z10
My Carrier: none

open a file from File Picker

Hi,

 

   i have to open a file using FilePicker.  After opening the filepicker object i am using a signal to connect to a slot and open the file selected.

 

bb::cascades::pickers::FilePicker *filePicker = new bb::cascades::pickers::FilePicker();

filePicker->open();
QObject::connect(filePicker,
	SIGNAL(fileSelected(const QStringList&)),
	this,
	SLOT(onFileSelected(const QStringList&)));

i tried various combination for opening the file but it is'nt working.

 

void FileBrowser::onFileSelected(const QStringList& list) {
qDebug () << "____XXXXX opening a file " << list[0]; QFile file (list[0]); file.open(QIODevice::ReadWrite); }
void FileBrowser::onFileSelected(const QStringList& list) {
	qDebug () << "____XXXXX opening a file " << list[0];
QFile file; file.setFileName(list[0]); file.open(QIODevice::ReadWrite); }

  Path is correct and the file exists.

 

 Please help me.. where am i wrong?

 

Regards,

Sanjeev

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: open a file from File Picker

[ Edited ]

Have you set the Shared Files permission (access_shared) in bar-descriptor.xml?


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 126
Registered: ‎06-25-2013
My Device: Z10
My Carrier: none

Re: open a file from File Picker

Yes i have the permission. and also getting the name and location of selected file in debug message.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: open a file from File Picker

How are you checking if the file is opening or not?


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 126
Registered: ‎06-25-2013
My Device: Z10
My Carrier: none

Re: open a file from File Picker

[ Edited ]

I didn't get you ?? How to check the file ??
When i call the file manager function screen pops up with the folder structure and and if a select a picture then it hides out and i am back to my application.

 

If i am wrong in opening a file then please help me. 

 

In my QSrtingList i receive list [0] as "/accounts/1000/shared/camera/IMG_00000001.jpg"  

How to open this file .

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: open a file from File Picker

So is your question, in fact, how to display a picture from a file picked by the user?


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Highlighted
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: open a file from File Picker

[ Edited ]

I'm going to assume this is what you are trying to do, you can create a ImageView from a filename like this...

 

ImageView* imageView1 = new ImageView();
imageView->setImage(Image(list[0]));

 

If this is not what you are trying to do then you really have to be clearer on what your problem is and what you want to achieve as your code supplied is clearly opening the file but your OP suggested it wasn't working!

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 126
Registered: ‎06-25-2013
My Device: Z10
My Carrier: none

Re: open a file from File Picker

[ Edited ]

Yes this was my question. I tried this method but still the same thing happened. when i selected the image; the control come and then hides out , back to my application.

 

One more thing i am using webview and this call is from html page. 

 

I need to open any file from file manager i.e.  .doc, .pdf, .mp3, .mp4 or any other format.

 

Regards,

 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: open a file from File Picker

Ok, can I suggest some basic reading on QML first...

 

http://developer.blackberry.com/native/documentation/cascades/ui/index.html

 

After you understand that then you can move on to how QML and C++ interact from a UI perpective...

 

http://developer.blackberry.com/native/documentation/cascades/dev/integrating_cpp_qml/

 

Once you've understood the dynamics behind how C++ and QML interact you will need to write some QML that you can then insert your ImageView in to.

 

Alternatively it can all be done in QML.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: open a file from File Picker

And now having seen your recent edit the question and problem has changed again!

 

For that I would recommend invocation, this is the process where you can utilise other apps already present on the phone to handle certain data types for you.

 

If you want to retain contorl then most native apps allow what's called a card invocation giving the impression that the image or document is being handled by your app rather than just being passed off to another...

 

http://developer.blackberry.com/native/documentation/cascades/device_platform/invocation/invocation_...


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.