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: 36
Registered: ‎09-17-2012
My Device: 9810-Playbooks-devalpha-Z10
My Carrier: Free mobile
Accepted Solution

can't connect fileSelected event from FilePicker

Hi,

 

I succeded to have filepicker work with simple cascade UI, but i need now to instanciate it from C instead of qml.

 

I wrote the following code from the Filepicker sample in the documentation

 

 

pickers::FilePicker* filePicker = NULL;

 

void FSLSoundwork::canceled(){

// we are supposed to get here when cancel is pressed

 

}

 

void FSLSoundwork::FSLFileSelected(const QStringList& selectedFiles){
// we are supposed to get here when a file is selected

}

 

FSLSoundwork::FSLSoundwork(bb::cascades::Application *app)
: QObject(app)
{

.

.

.

 

filePicker = new pickers::FilePicker(pickers::FileType:Smiley Surprisedther);
QStringList filters;
filters << "*.lib" << "*.snd";
filePicker->setFilter(filters);
filePicker->setTitle("Select File");
filePicker->setMode(pickers::FilePickerMode:Smiley Tongueicker);

 

QObject::connect(filePicker, SIGNAL(filesSelected(const QStringList &selectedFiles)), this, SLOT(FSLFileSelected(const QStringList &selectedFiles)));
QObject::connect(filePicker, SIGNAL(canceled()), this, SLOT(canceled()));

 

 

filePicker->open();

 

the open function is working fine, but I can't get any event from the Picker.

 

Any idea what is wrong with my code?

 

Thanks,

 

Fred

Developer
Posts: 16
Registered: ‎09-17-2012
My Device: Developer

Re: can't connect fileSelected event from FilePicker

The name of the signal is fileSelected, not filesSelected.

 

Not sure if this has any effect, but you don't need to give the parameter a name when you use it in SIGNAL or SLOT; you just need the variable type.

Highlighted
Developer
Posts: 36
Registered: ‎09-17-2012
My Device: 9810-Playbooks-devalpha-Z10
My Carrier: Free mobile

Re: can't connect fileSelected event from FilePicker

Thanks a lot for your help.

 

Hi BB people that maintain documentation. There's a mistake in the sample at https://developer.blackberry.com/cascades/reference/bb__cascades__pickers__filepicker.html

 

It's written :

 

The following example creates a FilePicker in Picker mode with a file type of Pictures.

 FilePicker* filePicker = new FilePicker(FileType:Smiley Tongueicture);
    filePicker->setTitle("Select Picture");
    filePicker->setMode(FilePickerMode:Smiley Tongueicker);
    filePicker->open();
 
Connect the signal fileSelected() with the slot.
    QObject::connect(filePicker, SIGNAL(filesSelected(const QStringList&)), this, SLOT(onFilesSelected(const QStringList&)));
    QObject::connect(filePicker, SIGNAL(canceled()), this, SLOT(onCanceled()));

 

Obviously the signal for fileselected must be:

QObject::connect(filePicker, SIGNAL(fileSelected(const QStringList&)), this, SLOT(onFilesSelected(const QStringList&)));

 

Cheers,

 

Fred