Delegate
Since: BlackBerry 10.2.0
Provides a generic delegate that instantiate an object when active and deletes it when it is not active.
Delegate is used for dynamically creating and deleting an object from QML.
The Delegate exposes an active property which can be used for explicitly loading and unloading the qml components. When the components have been loaded object will be set. Should the components fail to load object will be null and errorMessage will be set.
Page { attachedObjects: [ Delegate { id: sheetPageDelegate Page { Container { Button { text: "Close" onClicked: { sheet.close(); } } } } }, Sheet { id: sheet content: sheetPageDelegate.object onOpenedChanged: { if (opened) sheetPageDelegate.active = true; } onClosed: { sheetPageDelegate.active = false; } } ] Container { Button { text: "Open sheet" onClicked: { sheet.open(); } } } }
Overview
Inheritance
bb::cascades::BaseObject | ||
bb::cascades::Delegate |
QML properties
active | : bool |
component | : QDeclarativeComponent |
errorMessage | : QString [read-only] |
object | : QObject [read-only] |
source | : QUrl |
sourceComponent | : bb::cascades::QmlComponentDefinition |
objectName | : QString![]() |
parent | : QObject [read-only]![]() |
QML signals
Properties Index
bool | active |
QDeclarativeComponent | component |
QString | errorMessage [read-only] |
QObject | object [read-only] |
QUrl | source |
bb::cascades::QmlComponentDefinition | sourceComponent |
QString | objectName![]() |
QObject | parent [read-only]![]() |
Public Functions Index
Only has inherited public functions
void | setObjectName (const QString &name)![]() |
virtual Q_INVOKABLE QString | toDebugString () const ![]() |
Protected Functions Index
Only has inherited protected functions
BaseObject (QObject *parent=0)![]() |
Signals Index
void | activeChanged (bool active) |
void | componentChanged (QDeclarativeComponent *component) |
void | errorMessageChanged (const QString &errorMessage) |
void | objectChanged (QObject *object) |
void | sourceChanged (const QUrl &source) |
void | sourceComponentChanged (bb::cascades::QmlComponentDefinition *sourceComponent) |
void | creationCompleted ()![]() |
void | objectNameChanged (const QString &objectName)![]() |
Properties
bool
property controlling whether the object should be loaded or not
QDeclarativeComponent
A definition of inline component.
Defines the actual component which can be created from this delegate
By default this property is null
QString
returns an error message in case something goes wrong with loading and parsing the component defined by the source property or the inlined component
In case there are no errors, an empty string is returned.
string with the error message
QObject
Read only property with the actual object created from the source or component definition.
The returned object is a regular object instance, so it is possible to set properties, call functions or register for signals of the concrete class this object represents.
In case creating object from a source or sourceComponent fails, this property returns null.
Default value of this property (when no sourceComponent or source is set) is null
QUrl
Source loaded when active is true.
Currently supported URLs are relative, file:// or asset://. Loading files from network (http://, ftp://) or other schemas is not supported.
bb::cascades::QmlComponentDefinition
ComponentDefinition loaded when active is true.
The default value of this property is null
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
Public Functions
(Only has inherited public functions)
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
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
Signals
void
Emitted when a component is activated or deactivated.
Parameters | |
---|---|
active |
true when the created control is active (created) or false when inactive (deleted) |
void
Emitted when component property is changed.
Parameters | |
---|---|
component |
The component used for creating the object |
void
Emitted when loading component from specified source fails.
Parameters | |
---|---|
errorMessage |
The error messages returned by the QmlDocument loader |
void
Emitted when a new object is created or if the object is deleted.
Parameters | |
---|---|
object |
The actual created object if successfully created or null if deleted |
void
Emitted when source property is changed.
Parameters | |
---|---|
source |
The QUrl from which the component should be loaded |
void
Emitted when sourceComponent property is changed.
Parameters | |
---|---|
sourceComponent |
The new sourceComponent |
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