Option
Since: BlackBerry 10.0.0
#include <bb/cascades/Option>
An option that can be used in a list of selectable items.
The text, description, and image properties are displayed on the screen with the intention to give visual feedback to the user regarding the option. The value property is not visible and is intended as a utility for associating the option with a certain value.
An Option is intended to be used by any control that needs to display options as selectable items in some sort of list (e.g. the DropDown control).
Not all properties in the Option control need to be visually represented by a certain control. It is up to the control that uses it to implement whatever properties it needs to and determine how they are presented.
DropDown { title: "Reminder" enabled: true // image + text + description Option { imageSource: "asset:///alarm.png" text: "5 min" description: "Sets the alarm to 5 minutes" value: "5min" selected: true onSelectedChanged: { if (selected) { console.log("Setting alarm to 5 minutes."); } } } // text + description Option { text: "10 min" description: "Sets the alarm to 10 minutes" value: "10min" } // text only Option { text: "15 min" value: "15min" } }And another example in C++:
DropDown* dropDown = DropDown::create().title("DropDown"); dropDown->add(Option::create().text("Option 1")); dropDown->add(Option::create().text("Option 2")); dropDown->add(Option::create().text("Option 3")); rootContainer->add(dropDown);
Overview
Inheritance
bb::cascades::BaseObject | |||
bb::cascades::UIObject | |||
bb::cascades::Option |
QML properties
description | : QString |
enabled | : bool |
focused | : bool [read-only] |
image | : bb::cascades::Image |
imageSource | : QUrl |
selected | : bool |
text | : QString |
value | : QVariant |
attachedObjects | : QDeclarativeListProperty< QObject > [read-only]![]() |
objectName | : QString![]() |
parent | : QObject [read-only]![]() |
ui | : bb::cascades::UIConfig [read-only]![]() |
QML signals
Properties Index
QString | description |
bool | enabled |
bool | focused [read-only] |
QVariant | image |
QUrl | imageSource |
bool | selected |
QString | text |
QVariant | value |
QDeclarativeListProperty< QObject > | attachedObjects [read-only]![]() |
QString | objectName![]() |
QObject | parent [read-only]![]() |
bb::cascades::UIConfig | ui [read-only]![]() |
Public Functions Index
Option (Control *parent=0) | |
virtual | ~Option () |
const QString | description () const |
Image | image () const |
QUrl | imageSource () const |
bool | isEnabled () const |
bool | isFocused () const |
bool | isSelected () const |
Q_SLOT void | loseFocus () |
Q_SLOT void | requestFocus () |
Q_SLOT void | resetDescription () |
Q_SLOT void | resetEnabled () |
Q_SLOT void | resetImage () |
Q_SLOT void | resetImageSource () |
Q_SLOT void | resetSelected () |
Q_SLOT void | resetText () |
Q_SLOT void | resetValue () |
Q_SLOT void | setDescription (const QString &description) |
Q_SLOT void | setEnabled (bool enabled) |
Q_SLOT void | setImage (const Image &image) |
Q_SLOT void | setImageSource (const QUrl &source) |
Q_SLOT void | setSelected (bool selected) |
Q_SLOT void | setText (const QString &text) |
Q_SLOT void | setValue (const QVariant &value) |
const QString | text () const |
const QVariant | value () const |
virtual bool | event (QEvent *event)![]() |
void | setObjectName (const QString &name)![]() |
virtual Q_INVOKABLE QString | toDebugString () const ![]() |
Q_INVOKABLE bb::cascades::UIConfig * | ui () const ![]() |
Static Public Functions Index
Builder | create () |
Protected Functions Index
Only has inherited protected functions
BaseObject (QObject *parent=0)![]() | |
virtual void | connectNotify (const char *signal)![]() |
virtual void | disconnectNotify (const char *signal)![]() |
Signals Index
void | descriptionChanged (QString description) |
void | enabledChanged (bool enabled) |
void | focusedChanged (bool focused) |
void | imageChanged (const bb::cascades::Image &image) |
void | imageSourceChanged (const QUrl &imageSource) |
void | selectedChanged (bool selected) |
void | textChanged (QString text) |
void | valueChanged (QVariant value) |
void | creationCompleted ()![]() |
void | objectNameChanged (const QString &objectName)![]() |
Properties
bool
Indicates whether the option is enabled.
When the option is disabled, it cannot be selected by interaction. However, the programmatic API allows selection updates even for disabled options.
If true the option is enabled, if false it is disabled. The default value is true (enabled). The enabledChanged() signal is emitted when the enabled state changes.
BlackBerry 10.0.0
bool
Indicates the focused state of the option.
true if the option is focused, false otherwise. The default value is false (not focused). The focusedChanged() signal is emitted when the focused state changes.
BlackBerry 10.3.1
QVariant
An image set on this option.
This image can be used for giving the user additional information on this option (e.g. a contact image). The default value is a null image, indicating that no image is set. The imageChanged() signal is emitted when the image changes.
BlackBerry 10.0.0
QUrl
An image to display on the option.
If no image is set, an invalid QUrl will be returned. When changing the image source the imageSourceChanged() signal will be emitted.
BlackBerry 10.0.0
bool
Indicates the selected state of the option.
true if the option is selected, false otherwise. The default value is false (not selected). The selectedChanged() signal is emitted when the selected state changes.
BlackBerry 10.0.0
QString
A title text set on this option.
This is the primary textual representation of the option and should reflect what this option is. The default value is QString::null, indicating that no title text is set. The textChanged() signal is emitted when the text changes.
BlackBerry 10.0.0
QVariant
A value set on this option.
The value is intended to associate the option with a value and thus isn't visually represented. The value in question can be anything application specific, such as a pointer to a record set in a database. The default value is QVariant::Invalid, indicating that no value is set. The valueChanged() signal is emitted when the value changes.
BlackBerry 10.0.0
QDeclarativeListProperty< QObject >
A hierarchical list of the UIObject's attached objects.
BlackBerry 10.0.0
QString
This property is overridden from QObject.
QObject::objectName().
BlackBerry 10.0.0
QObject
A read-only property that represents this object's parent.
The parent of an object is specified using QObject::setParent(QObject*). The purpose of the property is to expose the object's parent to QML.
This property is read-only to prevent modifications from QML, where typically the parent is declaratively set. In C++ code, the parent can be explicitly set using QObject::setParent(QObject*), or implicitly set by adding it to a visual container.
The default value of this property is 0.
BlackBerry 10.0.0
bb::cascades::UIConfig
An object that gives access to unit conversion routines.
// Size using design units Container { preferredWidth: ui.du(12) preferredHeight: ui.du(5) } // Size using design units, snap to whole pixels Container { preferredWidth: ui.sdu(13.5) preferredHeight: ui.sdu(7.5) } // Size using absolute pixel values Container { preferredWidth: ui.px(150) preferredHeight: ui.px(50) }C++ use:
Container *container1 = Container::create().background(Color::Red); UIConfig *ui = container1->ui(); container1->setPreferredWidth(ui->du(12)); container1->setPreferredHeight(ui->du(5)); Container *container2 = Container::create().background(Color::Green); container2->setPreferredWidth(ui->sdu(13.5)); container2->setPreferredHeight(ui->sdu(7.5)); Container *container3 = Container::create().background(Color::Blue); container3->setPreferredWidth(ui->px(150)); container3->setPreferredHeight(ui->sdu(50));
Blackberry 10.3.0
Public Functions
Constructs an Option.
Parameters | |
---|---|
parent |
The parent Control of this Option. The default is 0 if you don't specify a parent. If not 0, the ownership of the constructed option will be transferred to the parent. |
BlackBerry 10.0.0
virtual
Destructor.
BlackBerry 10.0.0
const QString
Returns the description text set on this option.
QString::null is returned when description text was not set.
The description text set on this option.
BlackBerry 10.0.0
Image
Returns the image set on this option.
A null Image is returned when an image is not set.
The image set on this option.
BlackBerry 10.0.0
bool
Returns the enabled state of the option (i.e.
if it is enabled or not).
true if the option is enabled, false otherwise.
BlackBerry 10.0.0
bool
Returns the focused state of the option.
true if this option is focused, false otherwise.
BlackBerry 10.3.1
bool
Returns the selected state for the option.
true if this option is selected, false if it is not selected.
BlackBerry 10.0.0
Q_SLOT void
Resets the option to the default state (not focused).
BlackBerry 10.3.1
Q_SLOT void
Requests focus for the option.
BlackBerry 10.3.1
Q_SLOT void
Resets the description text on this option to a default value of QString::null.
The descriptionChanged() signal is emitted if the description text is changed.
BlackBerry 10.0.0
Q_SLOT void
Resets the image on this option to a default value of a null Image.
The imageChanged() signal is emitted if the image is reset.
BlackBerry 10.0.0
Q_SLOT void
Resets the Image on the option to its default, meaning that no image is set.
This function emits an imageSourceChanged() signal if the currently set image source changes.
BlackBerry 10.0.0
Q_SLOT void
Resets the option to the default state (not selected).
BlackBerry 10.0.0
Q_SLOT void
Resets the text on this option to a default value of QString::null.
The textChanged() signal is emitted if the text is reset.
BlackBerry 10.0.0
Q_SLOT void
Resets the value of this option.
The valueChanged() signal is emitted if the value is changed.
BlackBerry 10.0.0
Q_SLOT void
Sets the description text on this option.
The descriptionChanged() signal is emitted if the description text is changed.
Parameters | |
---|---|
description |
The new description text for this option. |
BlackBerry 10.0.0
Q_SLOT void
Sets the enabled state of the option (i.e.
if it is enabled or not).
Parameters | |
---|---|
enabled |
If true the option is enabled, if false the option is disabled. |
BlackBerry 10.0.0
Q_SLOT void
Sets the image on this option.
The imageChanged() signal is emitted if the image is changed.
Parameters | |
---|---|
image |
The new image for this option. |
BlackBerry 10.0.0
Q_SLOT void
Sets the Image for the option.
An invalid QUrl indicates no image. This function emits an imageSourceChanged() signal if the currently set image source changes.
Parameters | |
---|---|
source |
The image url. |
BlackBerry 10.0.0
Q_SLOT void
Sets the selected state for the option.
Parameters | |
---|---|
selected |
If true this option is selected, if false this option is not selected. |
BlackBerry 10.0.0
Q_SLOT void
Sets the new text on this option.
The textChanged() signal is emitted if the text is changed.
Parameters | |
---|---|
text |
The new text for this option. |
BlackBerry 10.0.0
Q_SLOT void
Sets the value on this option.
The valueChanged() signal is emitted if the value is changed.
Parameters | |
---|---|
value |
The new value for this option. |
BlackBerry 10.0.0
const QString
Returns the text set on this option.
QString::null is returned when text was not set.
The text set on this option.
BlackBerry 10.0.0
const QVariant
Returns the value set on this option.
The value set on this option.
BlackBerry 10.0.0
virtual bool 
Overloaded to implement the event mechanism in Cascades.
If this function is overridden, it must be called by the derived class for events to work properly in Cascades.
Parameters | |
---|---|
event |
The received event. |
True if the received event was recognized and processed, false otherwise.
BlackBerry 10.0.0
void 
Sets the objectName property.
Parameters | |
---|---|
name |
The new name for the object. |
BlackBerry 10.0.0
virtual Q_INVOKABLE QString 
Returns a debug string representing this object.
A debug string for the object.
BlackBerry 10.0.0
Q_INVOKABLE bb::cascades::UIConfig * 
Returns the UIConfig for this ui object.
The UIConfig can be used to perform unit conversions from design units (du) and snapped design units (sdu) to pixels.
Ownership remains with Cascades.
Container *container1 = Container::create().background(Color::Red); UIConfig *ui = container1->ui(); container1->setPreferredWidth(ui->du(12)); container1->setPreferredHeight(ui->du(5)); Container *container2 = Container::create().background(Color::Green); container2->setPreferredWidth(ui->sdu(13.5)); container2->setPreferredHeight(ui->sdu(7.5)); Container *container3 = Container::create().background(Color::Blue); container3->setPreferredWidth(ui->px(150)); container3->setPreferredHeight(ui->sdu(50));
The UIConfig for this ui object.
BlackBerry 10.3.0
Static Public Functions
Protected Functions
(Only has inherited protected functions)
Constructs an instance of BaseObject's subclass.
Parameters | |
---|---|
parent |
An optional parent, defaults to 0. |
BlackBerry 10.0.0
virtual void 
Overloaded to implement the event mechanism in Cascades.
If this function is overridden, it must be called by the derived class for events to work properly in Cascades.
Parameters | |
---|---|
signal |
The connected signal. |
BlackBerry 10.0.0
virtual void 
Overloaded to implement the event mechanism in Cascades.
If this function is overridden, it must be called by the derived class for events to work properly in Cascades.
Parameters | |
---|---|
signal |
The disconnected signal. |
BlackBerry 10.0.0
Signals
void
Emitted when this option's description text changes.
Parameters | |
---|---|
description |
The new description string, or QString::null if changed to an empty description. |
BlackBerry 10.0.0
void
Emitted when the enabled property on the option changes.
Parameters | |
---|---|
enabled |
If true the option is enabled, if false the option is disabled. |
BlackBerry 10.0.0
void
Emitted when the focused state changes.
Parameters | |
---|---|
focused |
The new focused state. If true this option is focused, if false this option is not focused. |
BlackBerry 10.3.1
void
Emitted when this option's image changes.
Parameters | |
---|---|
image |
The new image, or a null image if no image is shown. |
BlackBerry 10.0.0
void
Emitted when the image source changes.
Parameters | |
---|---|
imageSource |
The new image source, or an invalid QUrl if no source is set. |
BlackBerry 10.0.0
void
Emitted when the selected state changes.
Parameters | |
---|---|
selected |
The new selected state. If true this option is selected, if false this option is not selected. |
BlackBerry 10.0.0
void
Emitted when this option's title text changes.
Parameters | |
---|---|
text |
The new text string, or QString::null if changed to an empty text. |
BlackBerry 10.0.0
void
Emitted when this option's value changes.
Parameters | |
---|---|
value |
The new value, or QString::null if changed to an empty value. |
BlackBerry 10.0.0
void 
Emitted when this object is instantiated as a result of loading a QML document and creating the root node (only after the root component that caused this instantiation has completed construction), or when the object is being constructed from its builder class.
This signal indicates that the construction and initialization of the object has been completed, the properties are initialized, and any QML binding values have been assigned to the object.
This signal is not emitted when the object is constructed from C++ using the constructor. If the object is constructed using its builder class, the signal is emitted when the the builder class returns the fully constructed object.
This signal can be used when there is an activity that needs to be performed, such as a property state integrity verification after the object is instantiated from a QML document or a builder, but before control is returned to the application.
BlackBerry 10.0.0
void 
This signal is emitted when the objectName property is changed.
BlackBerry 10.0.0