Display selectedfile filepicker

Hey guys, I'm having some trouble getting the picture that I chose in the filepicker to display in an imageView.

I have already read other messages about displaying images of filepicker and I tried their solutions, but still can't make it work. My imageView remains empty even if the imageView.source is correct when I print it.

I am able to get the imageView to display a picture, if I combine the image as an asset, however.

If someone could point me in the right direction, it would be much appreciated.

In my qml file I have:

Page {
    Container {

        ImageView {
            id: imgView
            objectName: "imgView"
            layoutProperties: StackLayoutProperties {
                // make imgView to fill all available height
                spaceQuota: 1.0
            }
            verticalAlignment: VerticalAlignment.Center
            horizontalAlignment: HorizontalAlignment.Center
            scalingMethod: ScalingMethod.AspectFit
        }
        Button {
                        id: button
                        horizontalAlignment: HorizontalAlignment.Center
                        topMargin: 100

                        text: qsTr ("Choose Picture")
                        onClicked: picker.open()
                    }
    }
     attachedObjects: [
            FilePicker {
                id: picker
                title: qsTr ("File Picker")

                property string selectedFile

                onFileSelected: {
                    selectedFile = selectedFiles[0]
                    imgView.imageSource = selectedFile

                }
            }
        ]
}

access_shared

This line is present in the file of the bar - descriptor.xml?

Tags: BlackBerry Developers

Similar Questions

  • Bug example FX8 element "FileChooser?

     FileChooser fileChooser = new FileChooser();
     fileChooser.setTitle("Open Resource File");
     fileChooser.getExtensionFilters().addAll(
             new ExtensionFilter("Text Files", "*.txt"),
             new ExtensionFilter("Image Files", "*.png", "*.jpg", "*.gif"),
             new ExtensionFilter("Audio Files", "*.wav", "*.mp3", "*.aac"),
             new ExtensionFilter("All Files", "*.*"));
     File selectedFile = fileChooser.showOpenDialog(mainStage);
     if (selectedFile != null) {
        mainStage.display(selectedFile);
     }
    http://download.Java.NET/jdk8/jfxdocs/JavaFX/stage/filechooser.html

    Everything works except
        mainStage.display(selectedFile);
    There is no such thing as a Stage.Display? I'm curious to know if I'm missing something, or is there not in fact... If so what would we do for 'show' the ' selectedFile? Is this simply a placeholder to say "do what you do? I think it would be a commented section then... Oh wells. : P

    Edited by: KonradZuse 30 may 2013 14:59

    Is this simply a placeholder to say "do what you do?

    So I would say. Just read as a kind of comment todo for someone using the api.

    if (selectedFile != null) {
      // display selected file
    }
    

    You can connect an application for development of jira (minor priority) documentation if you wish...

  • FilePicker are not displayed

    It's so strange. On the Simulator, FilePicker.show () causes the FilePicker to display on the screen as you would expect. I can choose my file does my trick throughout the day. So, I signed the COD file and transferred to my phone to test it on my phone. Now when FilePicker.show () is called, nothing happens.

    The Simulator is a 9500 Storm running OS 5.0.0.224

    My phone is a 9530 Storm running OS 5.0.0.32 8

            private MenuItem setBackground = new MenuItem("Set Background", 100, 2) {
                public void run(){
                    final FilePicker filePicker = FilePicker.getInstance();
    
                    /*
                    String startPath = "file:///store/home/user/pictures/";
                    filePicker.setPath(startPath);
                    String filterString = "jpg";
                    filePicker.setFilter(filterString);
                    */
    
                    String path = filePicker.show();
    
                    if(path != null && setBackgroundPath(path)){
                        updateBackground();
                    }
                }
            };
    

    As you can see I even pointed out that some of the additional parameters to FilePicker in the hope that it would be useful. Made no difference. Any ideas?

    I am able to reproduce this problem and sent to our development team.  You can use the following as a temporary work around.

    -How to create a popup of file selection screen
    Article number: DB-00724

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800256/...

  • FilePicker on attachedObjects does not work?

    This is the simple app I'm working on that

    I want after a click in the action Go, a FilePicker bar will be shown, so I put the FilePicker on attachedObjects like this:

    // main.qml
    
    import bb.cascades 1.0
    
    NavigationPane {
        id: navigationPane
        backButtonsVisible: false
    
        // Create the initial screen
        Page {
            titleBar: TitleBar {
                title: qsTr("ExiView")
            }
    
            content: Container {
    
                TextArea {
                    id: lbl
                    editable: false
                    text: "Browse for an image, and ExiView will display its EXIF information for you."
                    textStyle {
                        color: Color.Black
                    }
    
                }
    
                // The file picker view mode selector
                DropDown {
                    id: pickerViewMode
    
                    horizontalAlignment: HorizontalAlignment.Center
    
                    title: qsTr("View Mode")
    
                    Option {
                        text: qsTr("Default")
                        value: FilePickerViewMode.Default
                        selected: true
                    }
    
                    Option {
                        text: qsTr("List View")
                        value: FilePickerViewMode.ListView
                    }
    
                    Option {
                        text: qsTr("Grid View")
                        value: FilePickerViewMode.GridView
                    }
                }
    
                // The file picker sort criterion selector
                DropDown {
                    id: pickerSortBy
    
                    horizontalAlignment: HorizontalAlignment.Center
    
                    title: qsTr("Sort by")
    
                    Option {
                        text: qsTr("Default")
                        value: FilePickerSortFlag.Default
                        selected: true
                    }
    
                    Option {
                        text: qsTr("Name")
                        value: FilePickerSortFlag.Name
                    }
    
                    Option {
                        text: qsTr("Date")
                        value: FilePickerSortFlag.Date
                    }
    
                    Option {
                        text: qsTr("Suffix")
                        value: FilePickerSortFlag.Suffix
                    }
    
                    Option {
                        text: qsTr("Size")
                        value: FilePickerSortFlag.Size
                    }
                }
    
                // The file picker sort order selector
                DropDown {
                    id: pickerSortOrder
    
                    horizontalAlignment: HorizontalAlignment.Center
    
                    title: qsTr("Sort order")
    
                    Option {
                        text: qsTr("Default")
                        value: FilePickerSortOrder.Default
                        selected: true
                    }
    
                    Option {
                        text: qsTr("Ascending")
                        value: FilePickerSortOrder.Ascending
                    }
    
                    Option {
                        text: qsTr("Descending")
                        value: FilePickerSortOrder.Descending
                    }
                }
            }
    
            actions: [
                // Create the "Push" action
                ActionItem {
                    title: "Go!"
                    ActionBar.placement: ActionBarPlacement.OnBar
    
                    // When this action is selected, create an object that's based
                    // on the ComponentDefinition below, and then push it on to
                    // the stack to display it
                    onTriggered: {
                        var newPage = detailsPage.createObject();
                        navigationPane.push(newPage);
                      // picker.open()
                    }
                }
            ]
    
            attachedObjects: [
    
                FilePicker {
                    id: picker
    
                    property string selectedFile
    
                    title: qsTr("Select image")
                    mode: pickerMode.selectedValue
                    type: FileType.Picture
                    viewMode: pickerViewMode.selectedValue
                    sortBy: pickerSortBy.selectedValue
                    sortOrder: pickerSortOrder.selectedValue
    
                    onFileSelected: {
                      //  selectedFile = selectedFiles[0]
                    }
                },
    
                ComponentDefinition {
                    id: detailsPage
                    source: "DetailsPage.qml"
                }
    
            ]
        } // end of Page
    }// end of NavigationPane
    

    It will not work. So where should I put the FilePicker?

    Hey anta40,

    Have you registered the Filepicker in main.cpp file?

    #include 
    
    // Register Filepicker
        qmlRegisterType("CustomComponent", 1, 0,"FilePicker");
    

    You will also need to include in the qml file

    import bb.cascades.pickers 1.0
    

    And in the .pro file

    LIBS   += -lbbcascadespickers
    

    Another thing, your withdrawal difficulty.

  • Create a FilePicker for QML images

    I have a FilePicker in QML, and it works, sort of. The type property seems to not be recognized because it displays all kinds of file types.

    attachedObjects: [
        FilePicker {
            id: imgPicker
            title: qsTr("Select a picture")
            type: FileType.Picture
            onFileSelected: {
                imageView.imageSource = selectedFiles[0];
            }
        }
    ]
    

    The type property is used similar to the example of the API:

    https://developer.BlackBerry.com/Cascades/reference/bb__cascades__pickers__filepicker.html

    However, I get the qml errors during execution of the code

    Warning: 14:35:15.118 file:///apps/x/native/assets//materials/x.qml:68: ReferenceError: Can't find variable: FileType
    

    And the FilePicker debug output suggests that it is created with type 'other ':

    Debug: 14:35:23.758 toTypedescList() returned  ("Other")
    Debug: 14:35:23.760  defaultFileNames  ""
    Debug: 14:35:23.766  ViewMode  0
    Debug: 14:35:23.767 The dataMap  QMap(("AllowOverwrite", QVariant(bool, false) ) ( "ImageCrop" ,  QVariant(bool, false) ) ( "Mode" ,  QVariant(QString, "Picker") ) ( "SortBy" ,  QVariant(QString, "Default") ) ( "SortOrder" ,  QVariant(QString, "Default") ) ( "Title" ,  QVariant(QString, "Select a picture") ) ( "Type" ,  QVariant(QString, "Other") ) ( "ViewMode" ,  QVariant(QString, "Default") ) )
    Debug: 14:35:23.790 The request string  "AllowOverwrite:b:false
    ImageCrop:b:false
    Mode::Picker
    SortBy::Default
    SortOrder::Default
    Title::Select a picture
    Type::Other
    ViewMode::Default
    

    What would be the correct type to use?

    FileType.Picture is good according to the docs. FileType is registered as qmlRegisterUncreatableType in your cpp file?

  • Photos poorly oriented when pulled from filepicker

    In my application I allow users to take a photo or select an image using the filepicker.  But when she shows the images in an imageView that they appear on the side and never in the correct position, no matter if they were taken without focus lock, or whatever.  When I invoke the display of images, howeverm images are always perfectly oriented.

    Is there anything I can do in my code to accommodate for this?  Orientation is off differently isn't tlike it's always oritented left, sometimes it's to the right, sometimes it is upside down, sometimes it's to the left.

    Hello

    I know exactly what is happening - I'm working on an app photo from last year, and I had the same problem.

    When the camera takes a photo, it adds some EXIF metadata in the JPEG file that indicates its "focus".

    In my opinion, the BB should add an ImageView option such as "autoOrient" so that it would automatically read and the picture rotates as appropriate before posting, but I don't think such a property exists. Thus, all the developers who want to display pictures must add this logic to their App (inefficient or what?)

    The good news is that there is a sample application that shows how to do this.  Take a look at the sample application "photobomber.

    I'll copy and paste the relevant code here:

    QImage PhotoBomberApp::getRotateImage(const QString imageFilePath)
    {
        //Load the image using QImage.
        QImage image = QImage(imageFilePath);
    
        ExifData *exifData = 0;
        ExifEntry *exifEntry = 0;
        int exifOrientation = 1;
    
        // Since the image will loose its exif data when its opened in a QImage
        // it has to be manually rotated according to the exif orientation.
        exifData = exif_data_new_from_file(imageFilePath.toLatin1().data());
    
        // Locate the orientation exif information.
        if (exifData != NULL) {
            for (int i = 0; i < EXIF_IFD_COUNT; i++) {
                exifEntry = exif_content_get_entry(exifData->ifd[i], EXIF_TAG_ORIENTATION);
    
                // If the entry corresponds to the orientation it will be a non zero pointer.
                if (exifEntry) {
                    exifOrientation = exif_get_short(exifEntry->data, exif_data_get_byte_order(exifData));
                    break;
                }
            }
        }
    
        // A transform will be used to rotate the image according to device and exif orientation.
        QTransform transform;
    
        qDebug() << "Exif data:" << exifOrientation;
    
        // It's a bit tricky to get the correct orientation of the image. A combination of
        // the way the the device is oriented and what the actual exif data says has to be used
        // in order to rotate it in the correct way.
        switch(exifOrientation) {
            case 1:
                // 0 degree rotation
                break;
            case 3:
                // 180 degree rotation
                transform.rotate(180);
                break;
            case 6:
                // 90 degree rotation
                transform.rotate(90);
                break;
            case 8:
                // 270 degree rotation
                transform.rotate(270);
                break;
            default:
                // Other orientations are mirrored orientations, do nothing.
                break;
        }
    
        // Perform the rotation of the image before its saved.
        image = image.transformed(transform);
    
        return image;
    }
    

    This code returns you a QImage, so you can or may not know how, then take that and display them in an ImageView. Incase it's useful, here's an example of my application relating to this code:

    QImage thisQImage = getRotateImage(...);
    
    bb::ImageData imageData = bb::ImageData::fromPixels(thisQImage.rgbSwapped().bits(), bb::PixelFormat::RGBX, thisQImage.width(), thisQImage.height(), thisQImage.bytesPerLine());
    
    bb::cascades::Image cascadesImage = imageData;
    
    imageView->setImage(cascadesImage);
    

    A final caveat is that doing each of these conversions between types of image data takes a little time, and so if you do it in the main thread of the application, you might or might not slow down the user interface.  I tried to move my loading image in another thread when it is possible, although I found (I think) the conversion in bb::cascades:Image does not work correctly if this isn't in the main thread, so I don't have this part and call setImage in the main thread.

    Hope that helps. Here the answer was simpler.

  • Filepicker several files

    Hi all

    Try using filepicker to take several pictures and place them in different imageViews at the same time.

    That's what I have so far for one frame at a time:

    {FilePicker}
    ID: picker1
    Title: qsTr ("select an image")
    string selectedFile property
    mode: FilePickerMode.Picker
    type: FileType.Picture
    directories: [' / accounts/1000/shared/camera "]
    viewMode: FilePickerViewMode.GridView
    sortBy: FilePickerSortFlag.Date
    sortOrder: FilePickerSortOrder.Descending
    imageCropEnabled: true
    onFileSelected: {}
    selectedFile = selectedFiles [0]
    imgView1.imageSource = "file://" + selectedFile
    imgView1.visible = true
    imgView1.scaleX = 1
    imgView1.scaleY = 1
    imgView1.rotationZ = 0

    }
    }

    It works perfectly if I want to select a photo and place it in imgView1... but I imgView 1, 2, 3, 4, 5, 6, 7.

    I would use the file selector choose 7 photos and put them in each imgView. I use FilePickerMultiple and it works great but can't seem to the get into each imgView separately.

    Tried:

    imgView1.imageSource, imgView2.imageSource, imgView3.imageSource is "file://" + selectedFile

    Does not return an error but puts only the last selected photo imgView3 and not imgView1 or 2.

    Any help would be amazing.

    THX.

    Dpcanada

    Thank you very much!!!

    Worked surprisingly well... you're a genius... you made my day.

    This is what the code looks like on your help:

    {FilePicker}
    ID: picker7
    Title: qsTr ("select an image")
    string selectedFile property
    mode: FilePickerMode.PickerMultiple
    type: FileType.Picture
    directories: [' / accounts/1000/shared/camera "]
    viewMode: FilePickerViewMode.GridView
    sortBy: FilePickerSortFlag.Date
    sortOrder: FilePickerSortOrder.Descending
    imageCropEnabled: true
    onFileSelected: {}
    for (var i = 0; i)< selectedfiles.length;="">
    var selectedFile = selectedFiles [i];
    imgView.imageSource = "file://" + selectedFiles [0]
    imgView1.imageSource = "file://" + selectedFiles [1]
    imgView2.imageSource = "file://" + selectedFiles [2]
    imgView3.imageSource = "file://" + selectedFiles [3]
    imgView4.imageSource = "file://" + selectedFiles [4]
    imgView5.imageSource = "file://" + selectedFiles [5]
    imgView6.imageSource = "file://" + selectedFiles [6]
    imgView7.imageSource = "file://" + selectedFiles [7]

    }
    }
    }

    He brings in 7 different photos in separate different imgViews... Impressive... just great!

    Thank you.

    dpcanada

  • Broken defaultSaveFileNames FilePicker component QML property?

    I'm trying to use a FilePicker to back up and restore user data in a JSON file.  I'm the pre-population of the property with the name of the file defaultSaveFileNames is to have its extension (".json") removed when the UI FilePicker slides in on the application user interface.  Is - this just broken?  There is a thread WebWorks describing the same problem here:

    http://supportforums.BlackBerry.com/T5/Web-and-WebWorks-development/invokeFilePicker-filter-options-...

            FilePicker {
                id: backupRestoreFilePicker
                type: FileType.Document
                directories : ["/accounts/1000/shared"]
                viewMode: FilePickerViewMode.ListView
            defaultSaveFileNames: ["userData.json"]
                onFileSelected: {
                    // handler code omitted
                }
            }
    

    The FilePicker UI does is display "userData" as suggests recorded file name.

    He adds the .json at the end of the file name, it it just hides the Textinput

    I use it and it adds .bar at the end of the file name, the user types into:
    {FilePicker}
    string saveName property
    ID: saver
    defaultSaveFileNames: ['.bar']
    mode: FilePickerMode.Saver
    Title: "download the update.
    directories: [' / accounts / "]

  • FilePicker

    I use filePicker to display images from a memory card. It works very well in 9550 Simulator, but not in the 9700. I tried to load the application on the device. It works for OS5, not on the OS6. Any work around that?

    Search the Forum, you will find that FilePicker has bug in 6.0. You can also look at the event log to find the error.

    If you have erections for 5.0 and 6.0, you can use this code for 6.0:

    FilePicker filePicker = FilePicker.getInstance();
    filePicker.setTitle(title);
    filePicker.setView(FilePicker.VIEW_PICTURES);
    

    It works very well without exceptions.

  • BB filepicker question plugin page reloading

    Hi friends,

    I'm working on the use of the BB filepicker plugin ( https://github.com/blackberry/WebWorks-Community-APIs/tree/master/Smartphone/FilePicker ) to use to load the filepicker to my HTML5/JS code. I have been able to launch successfully from the file browser and select a photo. But the minute I returned with URI (displayed in the alert box) photo and then try to view the image using the source URI... There is a html refresh happening. The page reloads and I am not able to view the image. I'm only able to print the URI for this on an alert box. Everything that I am doing wrong or is the normal behavior of the plugin? If so, some way around it?

    Sorry, my bad... I wrote a test application and it works exactly as expected. without recharging. The problem was with my own page for other reasons. Thank you

  • FilePicker fileSelected() signal do not work

    When I select a file in FilePicker, it must issue the signal of fileSelected() with QStringList to the URI of the file, but this QStringList is empty.

    FilePicker::selectedFiles() public method doesn't work either.

    How to know the files selected in FilePicker now?

    This SDK Gold is catastrophic for me.

    Help, help!

    OK, advice to all people using FilePicker:

    In the Archives of .pro:

    BEFORE GOLD SDK

    LIBS += -lfilepicker
    

    AFTER THE SDK GOLD

    LIBS += -lbbcascadespickersINCLUDEPATH += ${QNX_TARGET}/usr/include/bb/cascades/pickers
    

    Why the blackberry does not update this things to the docs?

  • Cannot connect FilePicker fileSelected events

    Hello

    I managed to get work with simple waterfall UI filepicker, but I need now to instantiate C instead of qml.

    I wrote the following code on the sample of Filepicker in 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 happen when a file is selected

    }

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

    .

    .

    .

    filePicker = new pickers::FilePicker (pickers::FileType:ther);
    QStringList filters;
    filters< "*.lib"=""><>
    filePicker-> setFilter (filters);
    filePicker-> setTitle ("select the file");
    filePicker-> setMode (pickers::FilePickerMode:icker);

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

    filePicker-> open();

    Open function works well, but I can't do any event in the selector.

    No idea what's wrong with my code?

    Thank you

    Fred

    The name of the signal is fileSelected, not filesSelected.

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

  • Reminders do not display or stick to the lock screen in iOS10

    IOS10 (10.0.1 and 10.0.2), on an iPhone (I use an iPhone 6), reminders are no longer reliable. I had several cases where the callback doesn't show even on the screen lock and many more times when the recall won't 'glue' to screen lock for more than a short period. Before iOS10, when you said to remind you at a certain time or place, the recall would display on the reliable lock screen until she has been marked as "completed".

    It is a major issue for people who depend on the application for the important tasks and calendar. There is a thread of any discussion on this point, for some reason, has been marked as "solved" even if a large number of people continues to post telling him that there is a problem for them too (as the thread located here). I wanted to start this new discussion which we hope will remain open until it is effectively resolved.

    Thank you!!! This is a HUGE problem!

    Since the update I had to reboot my phone EVERY day.

    Is the stick of reminders... or they do not. Lately they don't yet show upward. Then other things stick to the lock screen can't get rid of.

    Currently this feature on the phone is USELESS

  • Attached a letter not displayed

    Since I installed Sierra some attachments in the e-mail application do not display you can see that a letter to them.

    Sierra sometimes omits the last accessory and where there is a single attachment is it still missing.

    It seems to fail if the account is configured for IMAP access. POP access is not the problem. Better send Apple. Go to http://www.apple.com/feedback/macosx.html and em let know.

  • You can dim the brightness of the display of the alarm

    I tried the alarm on my new Apple Watch. The screen lights up a few minutes before the alarm sounds. It gradually increases in brightness. The problem is how bright Gets the display before the alarm sounds. He woke up before the alarm - it was like a flashlight shining in my eyes. Is it possible to adjust the brightness levels fir alarm?

    Try adjusting the brightness slider > https://help.apple.com/watch/#/apd62807a9f3

Maybe you are looking for