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
Highlighted
Developer
Posts: 239
Registered: ‎07-26-2010
My Device: Z10
My Carrier: Telkomsel
Accepted Solution

FilePicker on attachedObjects won't work?

This is the simple app I'm working on

 

ev.png

 

What I want is after the Go action bar is clicked, a FilePicker 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 won't run. So where should I put the FilePicker?

New Contributor
Posts: 7
Registered: ‎02-06-2012
My Device: Dev Alpha B
My Carrier: Rogers

Re: FilePicker on attachedObjects won't work?

Hey anta40, 

 

Have you registered the Filepicker in the main.cpp file?

#include <bb/cascades/pickers/FilePicker>

// Register Filepicker
	qmlRegisterType<bb::cascades::pickers::FilePicker>("CustomComponent", 1, 0,"FilePicker");

 You also need to include it in the qml file

import bb.cascades.pickers 1.0

 And in the .pro file

LIBS   += -lbbcascadespickers

 

Another thing, fix your indentation.