PickerItemComponent

Specifies a QML template used by a Picker to display items.

A PickerItemComponent can be attached to a Picker control using the Picker::pickerItemComponents property, and it can contain whatever QML components that you want to display in your picker item.

The type property is used to specify the type of item that the PickerItemComponent is used for (for example, you might have one PickerItemComponent used for "contacts" and another for "groups", each of which has a unique visual appearance).

Here's how to create a PickerItemComponent object and add it to a picker.

Picker {
    dataModel: XmlDataModel { source: "model.xml" }
    pickerItemComponents: [
        PickerItemComponent {
            type: "item"

            Container {
                layout: StackLayout {
                    orientation: Orientation.LeftToRight
                }
                ImageView {
                    imageSource: pickerItemData.image
                }
                Label {
                    text: pickerItemData.title
                }
            }
        }
    ]
}
Note:

This class can only be used in QML. In C++, the visuals for picker items can be managed using PickerProvider.

Since:

BlackBerry 10.1.0

QML properties

type: QString
content: QDeclarativeComponent

Properties Index

QStringtype
QDeclarativeComponentcontent

Public Functions Index

PickerItemComponent (QObject *parent=0)
QStringtype () const
voidsetType (const QString &typeString)
QDeclarativeComponent *content () const
voidsetContent (QDeclarativeComponent *component)

Signals Index

voidtypeChanged (const QString &type)
voidcontentChanged (QDeclarativeComponent *content)

Properties

QString type

The type of items this PickerItemComponent should be used for.

The default value is an empty string.

Since:

BlackBerry 10.1.0

QDeclarativeComponent content

Item visuals are defined on this property.

This is the default property for PickerItemComponent.

Since this property is of the type QDeclarativeComponent*, it does not contain instances of Control objects. Neither can object instances be assigned to this property. Instead, the QML from this property is used by a Picker to create item visuals of the specified type when needed. Which means that symbols only available in item visuals (for example pickerItemData) can be used in the QML on this property, since the symbols are not resolved until a Picker creates item visuals. On the other hand, symbols only available in the context of this PickerItemComponent cannot be used in the QML on this property, because item visuals are created in contexts of their own. Data can however be communicated to the item visuals by setting it as a dynamic property on this PickerItemComponent, or on the Picker.

Since:

BlackBerry 10.1.0

Public Functions

PickerItemComponent (

Constructs a PickerItemComponent instance.

Since:

BlackBerry 10.1.0

QString type ()

Gets the type for the picker item.

Return:

A string indicating the type of item.

Since:

BlackBerry 10.1.0

void setType (

Sets the type for the picker item.

Parameters
typeString

The type of item in the picker.

Since:

BlackBerry 10.1.0

QDeclarativeComponent * content ()

Gets the content for the picker item.

Return:

The content containing the item visuals.

Since:

BlackBerry 10.1.0

void setContent (
  • QDeclarativeComponent *component)

Sets the content for the picker item.

Parameters
component

The content containing the item visuals.

Since:

BlackBerry 10.1.0

Signals

void typeChanged (

Emitted when type has changed.

Since:

BlackBerry 10.1.0

void contentChanged (
  • QDeclarativeComponent *content)

Emitted when content has changed.

Since:

BlackBerry 10.1.0