[][src]Struct qt_qml::QQmlComponent

#[repr(C)]pub struct QQmlComponent { /* fields omitted */ }

Components are reusable, encapsulated QML types with well-defined interfaces.

C++ class: QQmlComponent.

C++ documentation:

Components are reusable, encapsulated QML types with well-defined interfaces.

A QQmlComponent instance can be created from a QML file. For example, if there is a main.qml file like this:

import QtQuick 2.0

Item { width: 200 height: 200 }

The following code loads this QML file as a component, creates an instance of this component using create(), and then queries the Item's width value:

QQmlEngine *engine = new QQmlEngine; QQmlComponent component(engine, QUrl::fromLocalFile("main.qml"));

QObject myObject = component.create(); QQuickItem item = qobject_cast<QQuickItem*>(myObject); int width = item->width(); // width = 200

To create instances of a component in code where a QQmlEngine instance is not available, you can use qmlContext() or qmlEngine(). For example, in the scenario below, child items are being created within a QQuickItem subclass:

void MyCppItem::init() { QQmlEngine engine = qmlEngine(this); // Or: // QQmlEngine engine = qmlContext(this)->engine(); QQmlComponent component(engine, QUrl::fromLocalFile("MyItem.qml")); QQuickItem childItem = qobject_cast<QQuickItem>(component.create()); childItem->setParentItem(this); }

Note that these functions will return null when called inside the constructor of a QObject subclass, as the instance will not yet have a context nor engine.

Network Components

If the URL passed to QQmlComponent is a network resource, or if the QML document references a network resource, the QQmlComponent has to fetch the network data before it is able to create objects. In this case, the QQmlComponent will have a Loading status. An application will have to wait until the component is Ready before calling QQmlComponent::create().

The following example shows how to load a QML file from a network resource. After creating the QQmlComponent, it tests whether the component is loading. If it is, it connects to the QQmlComponent::statusChanged() signal and otherwise calls the continueLoading() method directly. Note that QQmlComponent::isLoading() may be false for a network component if the component has been cached and is ready immediately.

MyApplication::MyApplication() { // ... component = new QQmlComponent(engine, QUrl("http://www.example.com/main.qml")); if (component->isLoading()) QObject::connect(component, SIGNAL(statusChanged(QQmlComponent::Status)), this, SLOT(continueLoading())); else continueLoading(); }

void MyApplication::continueLoading() { if (component->isError()) { qWarning() << component->errors(); } else { QObject *myObject = component->create(); } }

Methods

impl QQmlComponent[src]

pub fn slot_load_url(&self) -> Receiver<(*const QUrl,)>[src]

Load the QQmlComponent from the provided url.

Returns a built-in Qt slot QQmlComponent::loadUrl that can be passed to qt_core::Signal::connect.

C++ documentation:

Load the QQmlComponent from the provided url.

Ensure that the URL provided is full and correct, in particular, use QUrl::fromLocalFile() when loading a file from the local filesystem.

Relative paths will be resolved against QQmlEngine::baseUrl(), which is the current working directory unless specified.

pub fn slot_load_url2(&self) -> Receiver<(*const QUrl, CompilationMode)>[src]

Load the QQmlComponent from the provided url. If mode is Asynchronous, the component will be loaded and compiled asynchronously.

Returns a built-in Qt slot QQmlComponent::loadUrl that can be passed to qt_core::Signal::connect.

C++ documentation:

Load the QQmlComponent from the provided url. If mode is Asynchronous, the component will be loaded and compiled asynchronously.

Ensure that the URL provided is full and correct, in particular, use QUrl::fromLocalFile() when loading a file from the local filesystem.

Relative paths will be resolved against QQmlEngine::baseUrl(), which is the current working directory unless specified.

pub fn slot_set_data(&self) -> Receiver<(*const QByteArray, *const QUrl)>[src]

Sets the QQmlComponent to use the given QML data. If url is provided, it is used to set the component name and to provide a base path for items resolved by this component.

Returns a built-in Qt slot QQmlComponent::setData that can be passed to qt_core::Signal::connect.

C++ documentation:

Sets the QQmlComponent to use the given QML data. If url is provided, it is used to set the component name and to provide a base path for items resolved by this component.

pub fn status_changed(&self) -> Signal<(Status,)>[src]

Emitted whenever the component's status changes. status will be the new status.

Returns a built-in Qt signal QQmlComponent::statusChanged that can be passed to qt_core::Signal::connect.

C++ documentation:

Emitted whenever the component's status changes. status will be the new status.

Note: Notifier signal for property status.

pub fn progress_changed(&self) -> Signal<(c_double,)>[src]

Emitted whenever the component's loading progress changes. progress will be the current progress between 0.0 (nothing loaded) and 1.0 (finished).

Returns a built-in Qt signal QQmlComponent::progressChanged that can be passed to qt_core::Signal::connect.

C++ documentation:

Emitted whenever the component's loading progress changes. progress will be the current progress between 0.0 (nothing loaded) and 1.0 (finished).

Note: Notifier signal for property progress.

pub unsafe fn begin_create(
    &self,
    arg1: impl CastInto<Ptr<QQmlContext>>
) -> QPtr<QObject>
[src]

This method provides advanced control over component instance creation. In general, programmers should use QQmlComponent::create() to create object instances.

Calls C++ function: virtual QObject* QQmlComponent::beginCreate(QQmlContext* arg1).

C++ documentation:

This method provides advanced control over component instance creation. In general, programmers should use QQmlComponent::create() to create object instances.

Create an object instance from this component. Returns nullptr if creation failed. publicContext specifies the context within which to create the object instance.

When QQmlComponent constructs an instance, it occurs in three steps:

  1. The object hierarchy is created, and constant values are assigned.
  2. Property bindings are evaluated for the first time.
  3. If applicable, QQmlParserStatus::componentComplete() is called on objects.

QQmlComponent::beginCreate() differs from QQmlComponent::create() in that it only performs step 1. QQmlComponent::completeCreate() must be called to complete steps 2 and 3.

This breaking point is sometimes useful when using attached properties to communicate information to an instantiated component, as it allows their initial values to be configured before property bindings take effect.

The ownership of the returned object instance is transferred to the caller.

See also completeCreate() and QQmlEngine::ObjectOwnership.

pub unsafe fn complete_create(&self)[src]

This method provides advanced control over component instance creation. In general, programmers should use QQmlComponent::create() to create a component.

Calls C++ function: virtual void QQmlComponent::completeCreate().

C++ documentation:

This method provides advanced control over component instance creation. In general, programmers should use QQmlComponent::create() to create a component.

This function completes the component creation begun with QQmlComponent::beginCreate() and must be called afterwards.

See also beginCreate().

pub unsafe fn create_q_qml_context(
    &self,
    context: impl CastInto<Ptr<QQmlContext>>
) -> QPtr<QObject>
[src]

Create an object instance from this component. Returns nullptr if creation failed. context specifies the context within which to create the object instance.

Calls C++ function: virtual QObject* QQmlComponent::create(QQmlContext* context = …).

C++ documentation:

Create an object instance from this component. Returns nullptr if creation failed. context specifies the context within which to create the object instance.

If context is nullptr (the default), it will create the instance in the root context of the engine.

The ownership of the returned object instance is transferred to the caller.

If the object being created from this component is a visual item, it must have a visual parent, which can be set by calling QQuickItem::setParentItem(). See Concepts - Visual Parent in Qt Quick for more details.

See also QQmlEngine::ObjectOwnership.

pub unsafe fn create_q_qml_incubator2_q_qml_context(
    &self,
    arg1: impl CastInto<Ref<QQmlIncubator>>,
    context: impl CastInto<Ptr<QQmlContext>>,
    for_context: impl CastInto<Ptr<QQmlContext>>
)
[src]

Create an object instance from this component using the provided incubator. context specifies the context within which to create the object instance.

Calls C++ function: void QQmlComponent::create(QQmlIncubator& arg1, QQmlContext* context = …, QQmlContext* forContext = …).

C++ documentation:

Create an object instance from this component using the provided incubator. context specifies the context within which to create the object instance.

If context is 0 (the default), it will create the instance in the engine's root context.

forContext specifies a context that this object creation depends upon. If the forContext is being created asynchronously, and the QQmlIncubator::IncubationMode is QQmlIncubator::AsynchronousIfNested, this object will also be created asynchronously. If forContext is 0 (the default), the context will be used for this decision.

The created object and its creation status are available via the incubator.

See also QQmlIncubator.

pub unsafe fn create(&self) -> QPtr<QObject>[src]

Create an object instance from this component. Returns nullptr if creation failed. context specifies the context within which to create the object instance.

Calls C++ function: virtual QObject* QQmlComponent::create().

C++ documentation:

Create an object instance from this component. Returns nullptr if creation failed. context specifies the context within which to create the object instance.

If context is nullptr (the default), it will create the instance in the root context of the engine.

The ownership of the returned object instance is transferred to the caller.

If the object being created from this component is a visual item, it must have a visual parent, which can be set by calling QQuickItem::setParentItem(). See Concepts - Visual Parent in Qt Quick for more details.

See also QQmlEngine::ObjectOwnership.

pub unsafe fn create_q_qml_incubator_q_qml_context(
    &self,
    arg1: impl CastInto<Ref<QQmlIncubator>>,
    context: impl CastInto<Ptr<QQmlContext>>
)
[src]

Create an object instance from this component using the provided incubator. context specifies the context within which to create the object instance.

Calls C++ function: void QQmlComponent::create(QQmlIncubator& arg1, QQmlContext* context = …).

C++ documentation:

Create an object instance from this component using the provided incubator. context specifies the context within which to create the object instance.

If context is 0 (the default), it will create the instance in the engine's root context.

forContext specifies a context that this object creation depends upon. If the forContext is being created asynchronously, and the QQmlIncubator::IncubationMode is QQmlIncubator::AsynchronousIfNested, this object will also be created asynchronously. If forContext is 0 (the default), the context will be used for this decision.

The created object and its creation status are available via the incubator.

See also QQmlIncubator.

pub unsafe fn create_q_qml_incubator(
    &self,
    arg1: impl CastInto<Ref<QQmlIncubator>>
)
[src]

Create an object instance from this component using the provided incubator. context specifies the context within which to create the object instance.

Calls C++ function: void QQmlComponent::create(QQmlIncubator& arg1).

C++ documentation:

Create an object instance from this component using the provided incubator. context specifies the context within which to create the object instance.

If context is 0 (the default), it will create the instance in the engine's root context.

forContext specifies a context that this object creation depends upon. If the forContext is being created asynchronously, and the QQmlIncubator::IncubationMode is QQmlIncubator::AsynchronousIfNested, this object will also be created asynchronously. If forContext is 0 (the default), the context will be used for this decision.

The created object and its creation status are available via the incubator.

See also QQmlIncubator.

pub unsafe fn create_with_initial_properties_2a(
    &self,
    initial_properties: impl CastInto<Ref<QMapOfQStringQVariant>>,
    context: impl CastInto<Ptr<QQmlContext>>
) -> QPtr<QObject>
[src]

This is supported on cpp_lib_version="5.14.0" only.

Create an object instance of this component, and initialize its toplevel properties with initialProperties. context specifies the context where the object instance is to be created.

Calls C++ function: QObject* QQmlComponent::createWithInitialProperties(const QMap<QString, QVariant>& initialProperties, QQmlContext* context = …).

C++ documentation:

Create an object instance of this component, and initialize its toplevel properties with initialProperties. context specifies the context where the object instance is to be created.

This function was introduced in Qt 5.14.

See also QQmlComponent::create.

pub unsafe fn create_with_initial_properties_1a(
    &self,
    initial_properties: impl CastInto<Ref<QMapOfQStringQVariant>>
) -> QPtr<QObject>
[src]

This is supported on cpp_lib_version="5.14.0" only.

Create an object instance of this component, and initialize its toplevel properties with initialProperties. context specifies the context where the object instance is to be created.

Calls C++ function: QObject* QQmlComponent::createWithInitialProperties(const QMap<QString, QVariant>& initialProperties).

C++ documentation:

Create an object instance of this component, and initialize its toplevel properties with initialProperties. context specifies the context where the object instance is to be created.

This function was introduced in Qt 5.14.

See also QQmlComponent::create.

pub unsafe fn creation_context(&self) -> QPtr<QQmlContext>[src]

Returns the QQmlContext the component was created in. This is only valid for components created directly from QML.

Calls C++ function: QQmlContext* QQmlComponent::creationContext() const.

C++ documentation:

Returns the QQmlContext the component was created in. This is only valid for components created directly from QML.

pub unsafe fn engine(&self) -> QPtr<QQmlEngine>[src]

This is supported on cpp_lib_version="5.13.0" or cpp_lib_version="5.12.2" or cpp_lib_version="5.14.0" only.

Returns the QQmlEngine of this component.

Calls C++ function: QQmlEngine* QQmlComponent::engine() const.

C++ documentation:

Returns the QQmlEngine of this component.

This function was introduced in Qt 5.12.

pub unsafe fn error_string(&self) -> CppBox<QString>[src]

Calls C++ function: QString QQmlComponent::errorString() const.

pub unsafe fn errors(&self) -> CppBox<QListOfQQmlError>[src]

Returns the list of errors that occurred during the last compile or create operation. An empty list is returned if isError() is not set.

Calls C++ function: QList<QQmlError> QQmlComponent::errors() const.

C++ documentation:

Returns the list of errors that occurred during the last compile or create operation. An empty list is returned if isError() is not set.

pub unsafe fn is_error(&self) -> bool[src]

Returns true if status() == QQmlComponent::Error.

Calls C++ function: bool QQmlComponent::isError() const.

C++ documentation:

Returns true if status() == QQmlComponent::Error.

pub unsafe fn is_loading(&self) -> bool[src]

Returns true if status() == QQmlComponent::Loading.

Calls C++ function: bool QQmlComponent::isLoading() const.

C++ documentation:

Returns true if status() == QQmlComponent::Loading.

pub unsafe fn is_null(&self) -> bool[src]

Returns true if status() == QQmlComponent::Null.

Calls C++ function: bool QQmlComponent::isNull() const.

C++ documentation:

Returns true if status() == QQmlComponent::Null.

pub unsafe fn is_ready(&self) -> bool[src]

Returns true if status() == QQmlComponent::Ready.

Calls C++ function: bool QQmlComponent::isReady() const.

C++ documentation:

Returns true if status() == QQmlComponent::Ready.

pub unsafe fn load_url_1a(&self, url: impl CastInto<Ref<QUrl>>)[src]

Load the QQmlComponent from the provided url.

Calls C++ function: [slot] void QQmlComponent::loadUrl(const QUrl& url).

C++ documentation:

Load the QQmlComponent from the provided url.

Ensure that the URL provided is full and correct, in particular, use QUrl::fromLocalFile() when loading a file from the local filesystem.

Relative paths will be resolved against QQmlEngine::baseUrl(), which is the current working directory unless specified.

pub unsafe fn load_url_2a(
    &self,
    url: impl CastInto<Ref<QUrl>>,
    mode: CompilationMode
)
[src]

Load the QQmlComponent from the provided url. If mode is Asynchronous, the component will be loaded and compiled asynchronously.

Calls C++ function: [slot] void QQmlComponent::loadUrl(const QUrl& url, QQmlComponent::CompilationMode mode).

C++ documentation:

Load the QQmlComponent from the provided url. If mode is Asynchronous, the component will be loaded and compiled asynchronously.

Ensure that the URL provided is full and correct, in particular, use QUrl::fromLocalFile() when loading a file from the local filesystem.

Relative paths will be resolved against QQmlEngine::baseUrl(), which is the current working directory unless specified.

pub unsafe fn meta_object(&self) -> Ptr<QMetaObject>[src]

Calls C++ function: virtual const QMetaObject* QQmlComponent::metaObject() const.

pub unsafe fn from_q_object(
    parent: impl CastInto<Ptr<QObject>>
) -> QBox<QQmlComponent>
[src]

Calls C++ function: [constructor] void QQmlComponent::QQmlComponent(QObject* parent = …).

pub unsafe fn from_q_qml_engine_q_object(
    arg1: impl CastInto<Ptr<QQmlEngine>>,
    parent: impl CastInto<Ptr<QObject>>
) -> QBox<QQmlComponent>
[src]

Create a QQmlComponent with no data and give it the specified engine and parent. Set the data with setData().

Calls C++ function: [constructor] void QQmlComponent::QQmlComponent(QQmlEngine* arg1, QObject* parent = …).

C++ documentation:

Create a QQmlComponent with no data and give it the specified engine and parent. Set the data with setData().

pub unsafe fn from_q_qml_engine_q_string_q_object(
    arg1: impl CastInto<Ptr<QQmlEngine>>,
    file_name: impl CastInto<Ref<QString>>,
    parent: impl CastInto<Ptr<QObject>>
) -> QBox<QQmlComponent>
[src]

Create a QQmlComponent from the given fileName and give it the specified parent and engine.

Calls C++ function: [constructor] void QQmlComponent::QQmlComponent(QQmlEngine* arg1, const QString& fileName, QObject* parent = …).

C++ documentation:

Create a QQmlComponent from the given fileName and give it the specified parent and engine.

See also loadUrl().

pub unsafe fn from_q_qml_engine_q_string_compilation_mode_q_object(
    arg1: impl CastInto<Ptr<QQmlEngine>>,
    file_name: impl CastInto<Ref<QString>>,
    mode: CompilationMode,
    parent: impl CastInto<Ptr<QObject>>
) -> QBox<QQmlComponent>
[src]

Create a QQmlComponent from the given fileName and give it the specified parent and engine. If mode is Asynchronous, the component will be loaded and compiled asynchronously.

Calls C++ function: [constructor] void QQmlComponent::QQmlComponent(QQmlEngine* arg1, const QString& fileName, QQmlComponent::CompilationMode mode, QObject* parent = …).

C++ documentation:

Create a QQmlComponent from the given fileName and give it the specified parent and engine. If mode is Asynchronous, the component will be loaded and compiled asynchronously.

See also loadUrl().

pub unsafe fn from_q_qml_engine_q_url_q_object(
    arg1: impl CastInto<Ptr<QQmlEngine>>,
    url: impl CastInto<Ref<QUrl>>,
    parent: impl CastInto<Ptr<QObject>>
) -> QBox<QQmlComponent>
[src]

Create a QQmlComponent from the given url and give it the specified parent and engine.

Calls C++ function: [constructor] void QQmlComponent::QQmlComponent(QQmlEngine* arg1, const QUrl& url, QObject* parent = …).

C++ documentation:

Create a QQmlComponent from the given url and give it the specified parent and engine.

Ensure that the URL provided is full and correct, in particular, use QUrl::fromLocalFile() when loading a file from the local filesystem.

Relative paths will be resolved against QQmlEngine::baseUrl(), which is the current working directory unless specified.

See also loadUrl().

pub unsafe fn from_q_qml_engine_q_url_compilation_mode_q_object(
    arg1: impl CastInto<Ptr<QQmlEngine>>,
    url: impl CastInto<Ref<QUrl>>,
    mode: CompilationMode,
    parent: impl CastInto<Ptr<QObject>>
) -> QBox<QQmlComponent>
[src]

Create a QQmlComponent from the given url and give it the specified parent and engine. If mode is Asynchronous, the component will be loaded and compiled asynchronously.

Calls C++ function: [constructor] void QQmlComponent::QQmlComponent(QQmlEngine* arg1, const QUrl& url, QQmlComponent::CompilationMode mode, QObject* parent = …).

C++ documentation:

Create a QQmlComponent from the given url and give it the specified parent and engine. If mode is Asynchronous, the component will be loaded and compiled asynchronously.

Ensure that the URL provided is full and correct, in particular, use QUrl::fromLocalFile() when loading a file from the local filesystem.

Relative paths will be resolved against QQmlEngine::baseUrl(), which is the current working directory unless specified.

See also loadUrl().

pub unsafe fn new() -> QBox<QQmlComponent>[src]

Components are reusable, encapsulated QML types with well-defined interfaces.

Calls C++ function: [constructor] void QQmlComponent::QQmlComponent().

C++ documentation:

Components are reusable, encapsulated QML types with well-defined interfaces.

A QQmlComponent instance can be created from a QML file. For example, if there is a main.qml file like this:

import QtQuick 2.0

Item { width: 200 height: 200 }

The following code loads this QML file as a component, creates an instance of this component using create(), and then queries the Item's width value:

QQmlEngine *engine = new QQmlEngine; QQmlComponent component(engine, QUrl::fromLocalFile("main.qml"));

QObject myObject = component.create(); QQuickItem item = qobject_cast<QQuickItem*>(myObject); int width = item->width(); // width = 200

To create instances of a component in code where a QQmlEngine instance is not available, you can use qmlContext() or qmlEngine(). For example, in the scenario below, child items are being created within a QQuickItem subclass:

void MyCppItem::init() { QQmlEngine engine = qmlEngine(this); // Or: // QQmlEngine engine = qmlContext(this)->engine(); QQmlComponent component(engine, QUrl::fromLocalFile("MyItem.qml")); QQuickItem childItem = qobject_cast<QQuickItem>(component.create()); childItem->setParentItem(this); }

Note that these functions will return null when called inside the constructor of a QObject subclass, as the instance will not yet have a context nor engine.

Network Components

If the URL passed to QQmlComponent is a network resource, or if the QML document references a network resource, the QQmlComponent has to fetch the network data before it is able to create objects. In this case, the QQmlComponent will have a Loading status. An application will have to wait until the component is Ready before calling QQmlComponent::create().

The following example shows how to load a QML file from a network resource. After creating the QQmlComponent, it tests whether the component is loading. If it is, it connects to the QQmlComponent::statusChanged() signal and otherwise calls the continueLoading() method directly. Note that QQmlComponent::isLoading() may be false for a network component if the component has been cached and is ready immediately.

MyApplication::MyApplication() { // ... component = new QQmlComponent(engine, QUrl("http://www.example.com/main.qml")); if (component->isLoading()) QObject::connect(component, SIGNAL(statusChanged(QQmlComponent::Status)), this, SLOT(continueLoading())); else continueLoading(); }

void MyApplication::continueLoading() { if (component->isError()) { qWarning() << component->errors(); } else { QObject *myObject = component->create(); } }

pub unsafe fn from_q_qml_engine(
    arg1: impl CastInto<Ptr<QQmlEngine>>
) -> QBox<QQmlComponent>
[src]

Create a QQmlComponent with no data and give it the specified engine and parent. Set the data with setData().

Calls C++ function: [constructor] void QQmlComponent::QQmlComponent(QQmlEngine* arg1).

C++ documentation:

Create a QQmlComponent with no data and give it the specified engine and parent. Set the data with setData().

pub unsafe fn from_q_qml_engine_q_string(
    arg1: impl CastInto<Ptr<QQmlEngine>>,
    file_name: impl CastInto<Ref<QString>>
) -> QBox<QQmlComponent>
[src]

Create a QQmlComponent from the given fileName and give it the specified parent and engine.

Calls C++ function: [constructor] void QQmlComponent::QQmlComponent(QQmlEngine* arg1, const QString& fileName).

C++ documentation:

Create a QQmlComponent from the given fileName and give it the specified parent and engine.

See also loadUrl().

pub unsafe fn from_q_qml_engine_q_string_compilation_mode(
    arg1: impl CastInto<Ptr<QQmlEngine>>,
    file_name: impl CastInto<Ref<QString>>,
    mode: CompilationMode
) -> QBox<QQmlComponent>
[src]

Create a QQmlComponent from the given fileName and give it the specified parent and engine. If mode is Asynchronous, the component will be loaded and compiled asynchronously.

Calls C++ function: [constructor] void QQmlComponent::QQmlComponent(QQmlEngine* arg1, const QString& fileName, QQmlComponent::CompilationMode mode).

C++ documentation:

Create a QQmlComponent from the given fileName and give it the specified parent and engine. If mode is Asynchronous, the component will be loaded and compiled asynchronously.

See also loadUrl().

pub unsafe fn from_q_qml_engine_q_url(
    arg1: impl CastInto<Ptr<QQmlEngine>>,
    url: impl CastInto<Ref<QUrl>>
) -> QBox<QQmlComponent>
[src]

Create a QQmlComponent from the given url and give it the specified parent and engine.

Calls C++ function: [constructor] void QQmlComponent::QQmlComponent(QQmlEngine* arg1, const QUrl& url).

C++ documentation:

Create a QQmlComponent from the given url and give it the specified parent and engine.

Ensure that the URL provided is full and correct, in particular, use QUrl::fromLocalFile() when loading a file from the local filesystem.

Relative paths will be resolved against QQmlEngine::baseUrl(), which is the current working directory unless specified.

See also loadUrl().

pub unsafe fn from_q_qml_engine_q_url_compilation_mode(
    arg1: impl CastInto<Ptr<QQmlEngine>>,
    url: impl CastInto<Ref<QUrl>>,
    mode: CompilationMode
) -> QBox<QQmlComponent>
[src]

Create a QQmlComponent from the given url and give it the specified parent and engine. If mode is Asynchronous, the component will be loaded and compiled asynchronously.

Calls C++ function: [constructor] void QQmlComponent::QQmlComponent(QQmlEngine* arg1, const QUrl& url, QQmlComponent::CompilationMode mode).

C++ documentation:

Create a QQmlComponent from the given url and give it the specified parent and engine. If mode is Asynchronous, the component will be loaded and compiled asynchronously.

Ensure that the URL provided is full and correct, in particular, use QUrl::fromLocalFile() when loading a file from the local filesystem.

Relative paths will be resolved against QQmlEngine::baseUrl(), which is the current working directory unless specified.

See also loadUrl().

pub unsafe fn progress(&self) -> c_double[src]

The progress of loading the component, from 0.0 (nothing loaded) to 1.0 (finished).

Calls C++ function: double QQmlComponent::progress() const.

C++ documentation:

The progress of loading the component, from 0.0 (nothing loaded) to 1.0 (finished).

Access functions:

qreal progress() const

Notifier signal:

void progressChanged(qreal progress)

pub unsafe fn qt_metacall(
    &self,
    arg1: Call,
    arg2: c_int,
    arg3: *mut *mut c_void
) -> c_int
[src]

Calls C++ function: virtual int QQmlComponent::qt_metacall(QMetaObject::Call arg1, int arg2, void** arg3).

pub unsafe fn qt_metacast(&self, arg1: *const c_char) -> *mut c_void[src]

Calls C++ function: virtual void* QQmlComponent::qt_metacast(const char* arg1).

pub unsafe fn set_data(
    &self,
    arg1: impl CastInto<Ref<QByteArray>>,
    base_url: impl CastInto<Ref<QUrl>>
)
[src]

Sets the QQmlComponent to use the given QML data. If url is provided, it is used to set the component name and to provide a base path for items resolved by this component.

Calls C++ function: [slot] void QQmlComponent::setData(const QByteArray& arg1, const QUrl& baseUrl).

C++ documentation:

Sets the QQmlComponent to use the given QML data. If url is provided, it is used to set the component name and to provide a base path for items resolved by this component.

pub unsafe fn set_initial_properties(
    &self,
    component: impl CastInto<Ptr<QObject>>,
    properties: impl CastInto<Ref<QMapOfQStringQVariant>>
)
[src]

This is supported on cpp_lib_version="5.14.0" only.

Set toplevel properties of the component.

Calls C++ function: void QQmlComponent::setInitialProperties(QObject* component, const QMap<QString, QVariant>& properties).

C++ documentation:

Set toplevel properties of the component.

This method provides advanced control over component instance creation. In general, programmers should use QQmlComponent::createWithInitialProperties to create a component.

Use this method after beginCreate and before completeCreate has been called. If a provided property does not exist, a warning is issued.

This function was introduced in Qt 5.14.

pub unsafe fn static_meta_object() -> Ref<QMetaObject>[src]

Returns a reference to the staticMetaObject field.

pub unsafe fn status(&self) -> Status[src]

The component's current status.

Calls C++ function: QQmlComponent::Status QQmlComponent::status() const.

C++ documentation:

The component's current status.

Access functions:

QQmlComponent::Status status() const

Notifier signal:

void statusChanged(QQmlComponent::Status status)

pub unsafe fn tr(
    s: *const c_char,
    c: *const c_char,
    n: c_int
) -> CppBox<QString>
[src]

Calls C++ function: static QString QQmlComponent::tr(const char* s, const char* c, int n).

pub unsafe fn tr_utf8(
    s: *const c_char,
    c: *const c_char,
    n: c_int
) -> CppBox<QString>
[src]

Calls C++ function: static QString QQmlComponent::trUtf8(const char* s, const char* c, int n).

pub unsafe fn url(&self) -> CppBox<QUrl>[src]

The component URL. This is the URL passed to either the constructor, or the loadUrl(), or setData() methods.

Calls C++ function: QUrl QQmlComponent::url() const.

C++ documentation:

The component URL. This is the URL passed to either the constructor, or the loadUrl(), or setData() methods.

Access functions:

QUrl url() const

Trait Implementations

impl CppDeletable for QQmlComponent[src]

unsafe fn delete(&self)[src]

Destruct the QQmlComponent.

Calls C++ function: virtual [destructor] void QQmlComponent::~QQmlComponent().

C++ documentation:

Destruct the QQmlComponent.

impl Deref for QQmlComponent[src]

type Target = QObject

The resulting type after dereferencing.

fn deref(&self) -> &QObject[src]

Calls C++ function: QObject* static_cast<QObject*>(QQmlComponent* ptr).

impl DynamicCast<QQmlComponent> for QObject[src]

unsafe fn dynamic_cast(ptr: Ptr<QObject>) -> Ptr<QQmlComponent>[src]

Calls C++ function: QQmlComponent* dynamic_cast<QQmlComponent*>(QObject* ptr).

impl StaticDowncast<QQmlComponent> for QObject[src]

unsafe fn static_downcast(ptr: Ptr<QObject>) -> Ptr<QQmlComponent>[src]

Calls C++ function: QQmlComponent* static_cast<QQmlComponent*>(QObject* ptr).

impl StaticUpcast<QObject> for QQmlComponent[src]

unsafe fn static_upcast(ptr: Ptr<QQmlComponent>) -> Ptr<QObject>[src]

Calls C++ function: QObject* static_cast<QObject*>(QQmlComponent* ptr).

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.