![]() |
Qt 6.x
The Qt SDK
|
#include <qqmlcomponent_p.h>
Inheritance diagram for QQmlComponentPrivate:
Collaboration diagram for QQmlComponentPrivate:Classes | |
| struct | AnnotatedQmlError |
| struct | ConstructionState |
Public Types | |
| enum | CreateBehavior { CreateDefault , CreateWarnAboutRequiredProperties } |
| using | DeferredState = std::vector< ConstructionState > |
Public Types inherited from QObjectPrivate | |
| typedef void(* | StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **) |
| using | ConnectionDataPointer = QExplicitlySharedDataPointer< ConnectionData > |
Static Public Member Functions | |
| static void | setInitialProperties (QV4::ExecutionEngine *engine, QV4::QmlContext *qmlContext, const QV4::Value &o, const QV4::Value &v, RequiredProperties *requiredProperties, QObject *createdComponent, QQmlObjectCreator *creator) |
| \qmlmethod QtObject Component::createObject(QtObject parent, object properties) | |
| static QQmlError | unsetRequiredPropertyToQQmlError (const RequiredPropertyInfo &unsetRequiredProperty) |
| static void | beginDeferred (QQmlEnginePrivate *enginePriv, QObject *object, DeferredState *deferredState) |
| static void | completeDeferred (QQmlEnginePrivate *enginePriv, DeferredState *deferredState) |
| static void | complete (QQmlEnginePrivate *enginePriv, ConstructionState *state) |
| static QQmlProperty | removePropertyFromRequired (QObject *createdComponent, const QString &name, RequiredProperties *requiredProperties, QQmlEngine *engine, bool *wasInRequiredProperties=nullptr) |
| static QQmlComponentPrivate * | get (QQmlComponent *c) |
Static Public Member Functions inherited from QObjectPrivate | |
| static bool | removeConnection (Connection *c) |
| static QObjectPrivate * | get (QObject *o) |
| static const QObjectPrivate * | get (const QObject *o) |
| template<typename Func1 , typename Func2 > | |
| static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection) |
| template<typename Func1 , typename Func2 > | |
| static bool | disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot) |
| static QMetaObject::Connection | connectImpl (const QObject *sender, int signal_index, const QObject *receiver, void **slot, QtPrivate::QSlotObjectBase *slotObj, int type, const int *types, const QMetaObject *senderMetaObject) |
| static QMetaObject::Connection | connect (const QObject *sender, int signal_index, QtPrivate::QSlotObjectBase *slotObj, Qt::ConnectionType type) |
| static QMetaObject::Connection | connect (const QObject *sender, int signal_index, const QObject *receiver, QtPrivate::QSlotObjectBase *slotObj, Qt::ConnectionType type) |
| static bool | disconnect (const QObject *sender, int signal_index, void **slot) |
| static bool | disconnect (const QObject *sender, int signal_index, const QObject *receiver, void **slot) |
Definition at line 39 of file qqmlcomponent_p.h.
| using QQmlComponentPrivate::DeferredState = std::vector<ConstructionState> |
Definition at line 143 of file qqmlcomponent_p.h.
| Enumerator | |
|---|---|
| CreateDefault | |
| CreateWarnAboutRequiredProperties | |
Definition at line 163 of file qqmlcomponent_p.h.
|
inline |
Definition at line 44 of file qqmlcomponent_p.h.
| QObject * QQmlComponentPrivate::beginCreate | ( | QQmlRefPointer< QQmlContextData > | context | ) |
Definition at line 1007 of file qqmlcomponent.cpp.
References QQmlComponentPrivate::ConstructionState::addPendingRequiredProperty(), QQmlComponentPrivate::ConstructionState::appendCreatorErrors(), QQmlComponentPrivate::ConstructionState::clearRequiredProperties(), compilationUnit, context, QQmlObjectCreator::create(), QQmlType::createWithQQmlData(), creationContext, QQmlComponentPrivate::ConstructionState::creator(), QQmlEnginePrivate::dereferenceScarceResources(), e, engine, QQmlData::ensurePropertyCache(), QQmlComponentPrivate::ConstructionState::ensureRequiredPropertyStorage(), QQmlComponentPrivate::ConstructionState::errors, QQmlData::explicitIndestructibleSet, QQmlData::get(), QQmlEnginePrivate::get(), i, QQmlData::indestructible, info, QQmlComponentPrivate::ConstructionState::initCreator(), QQmlObjectCreator::InlineComponent, QV4::ExecutableCompilationUnit::inlineComponentId(), inlineComponentName, QQmlEnginePrivate::inProgressCreations, QQmlComponentPrivate::ConstructionState::isCompletePending(), QQmlType::isValid(), loadedType, QQmlObjectCreator::NormalObject, Q_ASSERT, qCDebug, qScopeGuard(), qWarning, QQmlEnginePrivate::referenceScarceResources(), QQmlData::rootObjectInCreation, QQmlComponentPrivate::ConstructionState::setCompletePending(), and state.
Here is the call graph for this function:
|
static |
Definition at line 1110 of file qqmlcomponent.cpp.
References QQmlComponentPrivate::ConstructionState::appendCreatorErrors(), creator, QQmlData::deferredData, QQmlData::get(), QQmlComponentPrivate::ConstructionState::initCreator(), QQmlEnginePrivate::inProgressCreations, Q_ASSERT, QQmlComponentPrivate::ConstructionState::setCompletePending(), and state.
Referenced by qmlExecuteDeferred().
Here is the call graph for this function:
Here is the caller graph for this function:| void QQmlComponentPrivate::clear | ( | ) |
Definition at line 314 of file qqmlcomponent.cpp.
References compilationUnit, inlineComponentName, loadedType, QQmlRefPointer< T >::reset(), typeData, and QQmlTypeData::unregisterCallback().
Referenced by loadUrl().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 1143 of file qqmlcomponent.cpp.
References QQmlComponentPrivate::ConstructionState::creator(), QQmlEnginePrivate::erroredBindings, QQmlObjectCreator::finalize(), QQmlEnginePrivate::inProgressCreations, QQmlComponentPrivate::ConstructionState::isCompletePending(), QQmlDelayedError::removeError(), QQmlComponentPrivate::ConstructionState::setCompletePending(), state, and QQmlEnginePrivate::warning().
Referenced by completeCreate(), completeDeferred(), and createWithProperties().
Here is the call graph for this function:
Here is the caller graph for this function:| void QQmlComponentPrivate::completeCreate | ( | ) |
Definition at line 1233 of file qqmlcomponent.cpp.
References complete(), engine, error, QQmlComponentPrivate::ConstructionState::errors, QQmlEnginePrivate::get(), QQmlComponentPrivate::ConstructionState::hasUnsetRequiredProperties(), QQmlEnginePrivate::inProgressCreations, QQmlComponentPrivate::ConstructionState::isCompletePending(), QQmlType::isValid(), loadedType, QQmlComponentPrivate::ConstructionState::requiredProperties(), QQmlComponentPrivate::ConstructionState::setCompletePending(), state, and unsetRequiredPropertyToQQmlError().
Here is the call graph for this function:
|
static |
Definition at line 1137 of file qqmlcomponent.cpp.
References complete(), and state.
Referenced by QQmlBindPrivate::buildBindEntries(), QtQuickPrivate::completeDeferred(), and qmlExecuteDeferred().
Here is the call graph for this function:
Here is the caller graph for this function:| QObject * QQmlComponentPrivate::createWithProperties | ( | QObject * | parent, |
| const QVariantMap & | properties, | ||
| QQmlContext * | context, | ||
| CreateBehavior | behavior = CreateDefault |
||
| ) |
Definition at line 936 of file qqmlcomponent.cpp.
References complete(), context, CreateWarnAboutRequiredProperties, doBeginCreate(), engine, error, QQmlEnginePrivate::get(), QQmlComponentPrivate::ConstructionState::hasUnsetRequiredProperties(), QQmlComponentPrivate::ConstructionState::isCompletePending(), QObjectData::parent, properties, qmlWarning(), QQmlComponent_setQmlParent(), QQmlComponentPrivate::ConstructionState::requiredProperties(), state, and unsetRequiredPropertyToQQmlError().
Here is the call graph for this function:| QObject * QQmlComponentPrivate::doBeginCreate | ( | QQmlComponent * | q, |
| QQmlContext * | context | ||
| ) |
Definition at line 326 of file qqmlcomponent.cpp.
References context, engine, qWarning, and QQmlEngine::rootContext().
Referenced by createWithProperties().
Here is the call graph for this function:
Here is the caller graph for this function:| void QQmlComponentPrivate::fromTypeData | ( | const QQmlRefPointer< QQmlTypeData > & | data | ) |
Definition at line 297 of file qqmlcomponent.cpp.
References QQmlComponentPrivate::ConstructionState::appendErrors(), compilationUnit, QQmlComponentPrivate::ConstructionState::errors, Q_ASSERT, QQmlRefPointer< T >::reset(), state, and url.
Referenced by QtObject::createQmlObject(), loadUrl(), and typeDataReady().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlinestatic |
Definition at line 156 of file qqmlcomponent_p.h.
References QObjectPrivate::get().
Referenced by TestCaseCollector::TestCaseCollector(), QQuickLoaderPrivate::_q_sourceLoaded(), QtObject::createComponent(), QtObject::createComponent(), QQmlObjectCreator::createComponent(), QtObject::createQmlObject(), QQuickListViewPrivate::getSectionItem(), QQmlIncubatorPrivate::incubateCppBasedComponent(), incubateObject(), QQuickStackElement::initialize(), QQDMIncubationTask::initializeRequiredProperties(), QQmlDelegateModelPrivate::object(), and QQuickLoaderPrivate::setInitialState().
Here is the call graph for this function:
Here is the caller graph for this function:| bool QQmlComponentPrivate::hadTopLevelRequiredProperties | ( | ) | const |
Definition at line 309 of file qqmlcomponent.cpp.
References QQmlObjectCreator::componentHadTopLevelRequiredProperties(), QQmlComponentPrivate::ConstructionState::creator(), and state.
Here is the call graph for this function:
|
virtual |
Definition at line 1457 of file qqmlcomponent.cpp.
References compilationUnit, QQmlIncubatorPrivate::compilationUnit, component(), context, creationContext, QQmlIncubatorPrivate::creator, engine, QQmlIncubatorPrivate::enginePriv, get(), QQmlEnginePrivate::get(), QQmlIncubatorPrivate::get(), QQmlEnginePrivate::incubate(), QV4::ExecutableCompilationUnit::inlineComponentId(), inlineComponentName, Q_ASSERT, QScopedPointer< T, Cleanup >::reset(), start, and QQmlIncubatorPrivate::subComponentToCreate.
Here is the call graph for this function:| void QQmlComponentPrivate::initializeObjectWithInitialProperties | ( | QV4::QmlContext * | qmlContext, |
| const QV4::Value & | valuemap, | ||
| QObject * | toCreate, | ||
| RequiredProperties * | requiredProperties | ||
| ) |
Definition at line 1920 of file qqmlcomponent.cpp.
References QQmlComponentPrivate::ConstructionState::creator(), engine, QJSEngine::handle(), QV4::StaticValue::isUndefined(), Q_ASSERT, qmlContext(), setInitialProperties(), state, and QV4::QObjectWrapper::wrap().
Here is the call graph for this function:
|
inline |
Definition at line 170 of file qqmlcomponent_p.h.
References QV4::CompiledData::Unit::ComponentsBound.
Referenced by QQuickLoaderPrivate::_q_sourceLoaded(), and QQDMIncubationTask::initializeRequiredProperties().
Here is the caller graph for this function:| void QQmlComponentPrivate::loadUrl | ( | const QUrl & | newUrl, |
| QQmlComponent::CompilationMode | mode = QQmlComponent::PreferSynchronous |
||
| ) |
Definition at line 769 of file qqmlcomponent.cpp.
References QQmlComponent::Asynchronous, QQmlTypeLoader::Asynchronous, QQmlEngine::baseUrl(), clear(), emit, engine, error, QQmlComponentPrivate::ConstructionState::errors, fromTypeData(), QQmlEnginePrivate::get(), QQmlTypeLoader::getType(), QDir::isAbsolutePath(), QUrl::isEmpty(), QUrl::isLocalFile(), QUrl::isRelative(), QQmlTypeLoader::PreferSynchronous, progress, QQmlTypeData::registerCallback(), QUrl::resolved(), QUrl::setScheme(), state, QUrl::toLocalFile(), QUrl::toString(), typeData, QQmlEnginePrivate::typeLoader, and url.
Here is the call graph for this function:
|
static |
Finds the matching top-level property with name name of the component createdComponent. If it was a required property or an alias to a required property contained in requiredProperties, it is removed from it. requiredProperties must be non-null.
If wasInRequiredProperties is non-null, the referenced boolean is set to true iff the property was found in requiredProperties.
Returns the QQmlProperty with name name (which might be invalid if there is no such property), for further processing (for instance, actually setting the property value).
Note: This method is used in QQmlComponent and QQmlIncubator to manage required properties. Most classes which create components should not need it and should only need to call setInitialProperties.
Definition at line 1178 of file qqmlcomponent.cpp.
References QQmlPropertyData::coreIndex(), QQmlPropertyIndex::coreIndex(), QHash< Key, T >::end(), engine, QHash< Key, T >::erase(), QHash< Key, T >::find(), QQmlPropertyPrivate::findAliasTarget(), QQmlPropertyPrivate::get(), QQmlData::get(), QQmlPropertyData::isAlias(), QQmlProperty::isValid(), it, and Q_ASSERT.
Referenced by QQmlIncubatorPrivate::incubate(), QQDMIncubationTask::initializeRequiredProperties(), setInitialProperties(), setInitialProperty(), and QQmlTableInstanceModel::setRequiredProperty().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
\qmlmethod QtObject Component::createObject(QtObject parent, object properties)
Creates and returns an object instance of this component that will have the given parent and properties. The properties argument is optional. Returns null if object creation fails.
The object will be created in the same context as the one in which the component was created. This function will always return null when called on components which were not created in QML.
If you wish to create an object without setting a parent, specify null for the parent value. Note that if the returned object is to be displayed, you must provide a valid parent value or set the returned object's \l{Item::parent}{parent} property, otherwise the object will not be visible.
If a parent is not provided to createObject(), a reference to the returned object must be held so that it is not destroyed by the garbage collector. This is true regardless of whether \l{Item::parent} is set afterwards, because setting the Item parent does not change object ownership. Only the graphical parent is changed.
As of {QtQuick 1.1}, this method accepts an optional properties argument that specifies a map of initial property values for the created object. These values are applied before the object creation is finalized. This is more efficient than setting property values after object creation, particularly where large sets of property values are defined, and also allows property bindings to be set up (using \l{Qt::binding}{Qt.binding}) before the object is created.
The properties argument is specified as a map of property-value items. For example, the code below creates an object with initial x and y values of 100 and 100, respectively:
\qml const component = Qt.createComponent("Button.qml"); if (component.status === Component.Ready) { component.createObject(parent, { x: 100, y: 100 }); } \endqml
Dynamically created instances can be deleted with the destroy() method. See \l {Dynamic QML Object Creation from JavaScript} for more information.
Definition at line 1617 of file qqmlcomponent.cpp.
References QLatin1StringView::arg(), creator, engine, QV4::ObjectIterator::EnumerableOnly, error, frame, i, it, o, properties, qmlContext(), QQmlEngine::qmlEngine(), qmlWarning(), removePendingQPropertyBinding(), and removePropertyFromRequired().
Referenced by QQuickStackElement::initialize(), initializeObjectWithInitialProperties(), and QV4::QmlIncubatorObject::setInitialState().
Here is the call graph for this function:
Here is the caller graph for this function:| bool QQmlComponentPrivate::setInitialProperty | ( | QObject * | component, |
| const QString & | name, | ||
| const QVariant & | value | ||
| ) |
Definition at line 367 of file qqmlcomponent.cpp.
References arg, base, QV4::ExecutionEngine::catchExceptionAsQmlError(), creator, QQmlComponentPrivate::ConstructionState::creator(), QV4::Scope::engine, engine, error, QQmlPropertyPrivate::get(), QJSEngine::handle(), QV4::EngineBase::hasException, QQmlComponentPrivate::ConstructionState::hasUnsetRequiredProperties(), i, QQmlProperty::index(), QQmlProperty::isBindable(), QQmlProperty::isValid(), QV4::ExecutionEngine::metaTypeToJS(), QV4::ExecutionEngine::newString(), QQmlProperty::object, QQmlMetaType::prettyTypeName(), properties, qmlWarning(), QStringLiteral, removePendingQPropertyBinding(), removePropertyFromRequired(), QQmlComponentPrivate::ConstructionState::requiredProperties(), state, url, QV4::QObjectWrapper::wrap(), and QQmlPropertyPrivate::writeValueProperty().
Here is the call graph for this function:
|
overridevirtual |
Reimplemented from QQmlTypeData::TypeDataCallback.
Definition at line 288 of file qqmlcomponent.cpp.
|
overridevirtual |
Reimplemented from QQmlTypeData::TypeDataCallback.
Definition at line 274 of file qqmlcomponent.cpp.
References emit, fromTypeData(), progress, Q_ASSERT, QQmlRefPointer< T >::reset(), and typeData.
Here is the call graph for this function:
|
static |
Definition at line 1677 of file qqmlcomponent.cpp.
References RequiredPropertyInfo::aliasesToRequired, QLatin1StringView::arg(), QV4::CompiledData::Location::column(), error, RequiredPropertyInfo::fileUrl, info, QV4::CompiledData::Location::line(), RequiredPropertyInfo::location, RequiredPropertyInfo::propertyName, and qmlConvertSourceCoordinate< quint32, int >().
Referenced by completeCreate(), createWithProperties(), QQmlIncubatorPrivate::incubate(), and QQmlIncubatorPrivate::incubateCppBasedComponent().
Here is the call graph for this function:
Here is the caller graph for this function:| QQmlRefPointer<QV4::ExecutableCompilationUnit> QQmlComponentPrivate::compilationUnit |
Definition at line 81 of file qqmlcomponent_p.h.
Referenced by TestCaseCollector::TestCaseCollector(), beginCreate(), clear(), fromTypeData(), incubateObject(), and QQmlComponentPrivate::ConstructionState::initCreator().
| QQmlGuardedContextData QQmlComponentPrivate::creationContext |
Definition at line 152 of file qqmlcomponent_p.h.
Referenced by beginCreate(), QtObject::createComponent(), QtObject::createComponent(), QQmlObjectCreator::createComponent(), incubateObject(), and QQmlComponentPrivate::ConstructionState::initCreator().
| QQmlEngine* QQmlComponentPrivate::engine |
Definition at line 151 of file qqmlcomponent_p.h.
Referenced by beginCreate(), completeCreate(), createWithProperties(), doBeginCreate(), incubateObject(), initializeObjectWithInitialProperties(), loadUrl(), removePropertyFromRequired(), setInitialProperties(), and setInitialProperty().
| std::unique_ptr<QString> QQmlComponentPrivate::inlineComponentName |
Definition at line 73 of file qqmlcomponent_p.h.
Referenced by beginCreate(), clear(), and incubateObject().
| QQmlType QQmlComponentPrivate::loadedType |
Definition at line 82 of file qqmlcomponent_p.h.
Referenced by beginCreate(), clear(), and completeCreate().
| qreal QQmlComponentPrivate::progress |
Definition at line 72 of file qqmlcomponent_p.h.
Referenced by QtObject::createQmlObject(), loadUrl(), typeDataProgress(), and typeDataReady().
| int QQmlComponentPrivate::start |
Definition at line 77 of file qqmlcomponent_p.h.
Referenced by incubateObject().
| ConstructionState QQmlComponentPrivate::state |
Definition at line 141 of file qqmlcomponent_p.h.
Referenced by beginCreate(), beginDeferred(), complete(), completeCreate(), completeDeferred(), createWithProperties(), fromTypeData(), hadTopLevelRequiredProperties(), initializeObjectWithInitialProperties(), loadUrl(), and setInitialProperty().
| QQmlRefPointer<QQmlTypeData> QQmlComponentPrivate::typeData |
Definition at line 65 of file qqmlcomponent_p.h.
Referenced by clear(), loadUrl(), and typeDataReady().
| QUrl QQmlComponentPrivate::url |
Definition at line 71 of file qqmlcomponent_p.h.
Referenced by fromTypeData(), loadUrl(), and setInitialProperty().