Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QQmlComponentPrivate Class Reference

#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>
 

Public Member Functions

 QQmlComponentPrivate ()
 
void loadUrl (const QUrl &newUrl, QQmlComponent::CompilationMode mode=QQmlComponent::PreferSynchronous)
 
QQmlType loadedType () const
 
QObjectbeginCreate (QQmlRefPointer< QQmlContextData >)
 
void completeCreate ()
 
void initializeObjectWithInitialProperties (QV4::QmlContext *qmlContext, const QV4::Value &valuemap, QObject *toCreate, RequiredProperties *requiredProperties)
 
virtual void incubateObject (QQmlIncubator *incubationTask, QQmlComponent *component, QQmlEngine *engine, const QQmlRefPointer< QQmlContextData > &context, const QQmlRefPointer< QQmlContextData > &forContext)
 
void typeDataReady (QQmlTypeData *) override
 
void typeDataProgress (QQmlTypeData *, qreal) override
 
void fromTypeData (const QQmlRefPointer< QQmlTypeData > &data)
 
bool hadTopLevelRequiredProperties () const
 
void clear ()
 
QObjectdoBeginCreate (QQmlComponent *q, QQmlContext *context)
 
bool setInitialProperty (QObject *component, const QString &name, const QVariant &value)
 
QObjectcreateWithProperties (QObject *parent, const QVariantMap &properties, QQmlContext *context, CreateBehavior behavior=CreateDefault, bool createFromQml=false)
 
bool isBound () const
 
void prepareLoadFromModule (QAnyStringView uri, QAnyStringView typeName, QQmlTypeLoader::Mode mode)
 
void completeLoadFromModule (QAnyStringView uri, QAnyStringView typeName)
 
- Public Member Functions inherited from QObjectPrivate
void ensureExtraData ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
virtual ~QObjectPrivate ()
 
void deleteChildren ()
 
void clearBindingStorage ()
 
void checkForIncompatibleLibraryVersion (int version) const
 
void setParent_helper (QObject *)
 
void moveToThread_helper ()
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData, QBindingStatus *status)
 
QObjectList receiverList (const char *signal) const
 
void ensureConnectionData ()
 
void addConnection (int signal, Connection *c)
 
int signalIndex (const char *signalName, const QMetaObject **meta=nullptr) const
 
bool isSignalConnected (uint signalIdx, bool checkDeclarative=true) const
 
bool maybeSignalConnected (uint signalIndex) const
 
bool isDeclarativeSignalConnected (uint signalIdx) const
 
void connectNotify (const QMetaMethod &signal)
 
void disconnectNotify (const QMetaMethod &signal)
 
void reinitBindingStorageAfterThreadMove ()
 
virtual std::string flagsForDumping () const
 
virtual void writeToDebugStream (QDebug &) const
 
QtPrivate::QPropertyAdaptorSlotObjectgetPropertyAdaptorSlotObject (const QMetaProperty &property)
 
- Public Member Functions inherited from QObjectData
 QObjectData ()=default
 
virtual ~QObjectData ()=0
 
QMetaObjectdynamicMetaObject () const
 
- Public Member Functions inherited from QQmlTypeData::TypeDataCallback
virtual ~TypeDataCallback ()
 

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 QQmlComponentPrivateget (QQmlComponent *c)
 
- Static Public Member Functions inherited from QObjectPrivate
static bool removeConnection (Connection *c)
 
static QObjectPrivateget (QObject *o)
 
static const QObjectPrivateget (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)
 

Public Attributes

QQmlRefPointer< QQmlTypeDatatypeData
 
QQmlRefPointer< LoadHelperloadHelper
 
QUrl url
 
qreal progress
 
std::unique_ptr< QStringinlineComponentName
 
int start
 
QQmlRefPointer< QV4::ExecutableCompilationUnitcompilationUnit
 
ConstructionState state
 
QQmlEngineengine
 
QQmlGuardedContextData creationContext
 
- Public Attributes inherited from QObjectPrivate
ExtraDataextraData
 
QAtomicPointer< QThreadDatathreadData
 
QAtomicPointer< ConnectionDataconnections
 
union { 
 
   QObject *   currentChildBeingDeleted 
 
   QAbstractDeclarativeData *   declarativeData 
 
};  
 
QAtomicPointer< QtSharedPointer::ExternalRefCountDatasharedRefcount
 
- Public Attributes inherited from QObjectData
QObjectq_ptr
 
QObjectparent
 
QObjectList children
 
uint isWidget: 1
 
uint blockSig: 1
 
uint wasDeleted: 1
 
uint isDeletingChildren: 1
 
uint sendChildEvents: 1
 
uint receiveChildEvents: 1
 
uint isWindow: 1
 
uint deleteLaterCalled: 1
 
uint isQuickItem: 1
 
uint willBeWidget: 1
 
uint wasWidget: 1
 
uint receiveParentEvents: 1
 
uint unused: 20
 
QAtomicInt postedEvents
 
QDynamicMetaObjectDatametaObject
 
QBindingStorage bindingStorage
 

Detailed Description

Definition at line 39 of file qqmlcomponent_p.h.

Member Typedef Documentation

◆ DeferredState

Definition at line 160 of file qqmlcomponent_p.h.

Member Enumeration Documentation

◆ CreateBehavior

Enumerator
CreateDefault 
CreateWarnAboutRequiredProperties 

Definition at line 180 of file qqmlcomponent_p.h.

Constructor & Destructor Documentation

◆ QQmlComponentPrivate()

QQmlComponentPrivate::QQmlComponentPrivate ( )
inline

Definition at line 44 of file qqmlcomponent_p.h.

Member Function Documentation

◆ beginCreate()

QObject * QQmlComponentPrivate::beginCreate ( QQmlRefPointer< QQmlContextData > context)

Definition at line 1044 of file qqmlcomponent.cpp.

◆ beginDeferred()

void QQmlComponentPrivate::beginDeferred ( QQmlEnginePrivate * enginePriv,
QObject * object,
DeferredState * deferredState )
static

Definition at line 1158 of file qqmlcomponent.cpp.

◆ clear()

void QQmlComponentPrivate::clear ( )

Definition at line 318 of file qqmlcomponent.cpp.

◆ complete()

void QQmlComponentPrivate::complete ( QQmlEnginePrivate * enginePriv,
ConstructionState * state )
static

Definition at line 1191 of file qqmlcomponent.cpp.

◆ completeCreate()

void QQmlComponentPrivate::completeCreate ( )

Definition at line 1281 of file qqmlcomponent.cpp.

◆ completeDeferred()

void QQmlComponentPrivate::completeDeferred ( QQmlEnginePrivate * enginePriv,
QQmlComponentPrivate::DeferredState * deferredState )
static

Definition at line 1185 of file qqmlcomponent.cpp.

◆ completeLoadFromModule()

void QQmlComponentPrivate::completeLoadFromModule ( QAnyStringView uri,
QAnyStringView typeName )

Definition at line 1405 of file qqmlcomponent.cpp.

◆ createWithProperties()

QObject * QQmlComponentPrivate::createWithProperties ( QObject * parent,
const QVariantMap & properties,
QQmlContext * context,
CreateBehavior behavior = CreateDefault,
bool createFromQml = false )

Definition at line 950 of file qqmlcomponent.cpp.

◆ doBeginCreate()

QObject * QQmlComponentPrivate::doBeginCreate ( QQmlComponent * q,
QQmlContext * context )

Definition at line 334 of file qqmlcomponent.cpp.

◆ fromTypeData()

void QQmlComponentPrivate::fromTypeData ( const QQmlRefPointer< QQmlTypeData > & data)

Definition at line 300 of file qqmlcomponent.cpp.

◆ get()

static QQmlComponentPrivate * QQmlComponentPrivate::get ( QQmlComponent * c)
inlinestatic

Definition at line 173 of file qqmlcomponent_p.h.

◆ hadTopLevelRequiredProperties()

bool QQmlComponentPrivate::hadTopLevelRequiredProperties ( ) const

Definition at line 313 of file qqmlcomponent.cpp.

◆ incubateObject()

void QQmlComponentPrivate::incubateObject ( QQmlIncubator * incubationTask,
QQmlComponent * component,
QQmlEngine * engine,
const QQmlRefPointer< QQmlContextData > & context,
const QQmlRefPointer< QQmlContextData > & forContext )
virtual

Definition at line 1608 of file qqmlcomponent.cpp.

◆ initializeObjectWithInitialProperties()

void QQmlComponentPrivate::initializeObjectWithInitialProperties ( QV4::QmlContext * qmlContext,
const QV4::Value & valuemap,
QObject * toCreate,
RequiredProperties * requiredProperties )

Definition at line 2072 of file qqmlcomponent.cpp.

◆ isBound()

bool QQmlComponentPrivate::isBound ( ) const
inline

Definition at line 188 of file qqmlcomponent_p.h.

◆ loadedType()

QQmlType QQmlComponentPrivate::loadedType ( ) const
inline

Definition at line 49 of file qqmlcomponent_p.h.

◆ loadUrl()

void QQmlComponentPrivate::loadUrl ( const QUrl & newUrl,
QQmlComponent::CompilationMode mode = QQmlComponent::PreferSynchronous )

Definition at line 783 of file qqmlcomponent.cpp.

◆ prepareLoadFromModule()

void QQmlComponentPrivate::prepareLoadFromModule ( QAnyStringView uri,
QAnyStringView typeName,
QQmlTypeLoader::Mode mode )

Definition at line 1393 of file qqmlcomponent.cpp.

◆ removePropertyFromRequired()

QQmlProperty QQmlComponentPrivate::removePropertyFromRequired ( QObject * createdComponent,
const QString & name,
RequiredProperties * requiredProperties,
QQmlEngine * engine,
bool * wasInRequiredProperties = nullptr )
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 1226 of file qqmlcomponent.cpp.

◆ setInitialProperties()

void QQmlComponentPrivate::setInitialProperties ( QV4::ExecutionEngine * engine,
QV4::QmlContext * qmlContext,
const QV4::Value & o,
const QV4::Value & v,
RequiredProperties * requiredProperties,
QObject * createdComponent,
QQmlObjectCreator * creator )
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.

See also
incubateObject()

Definition at line 1768 of file qqmlcomponent.cpp.

◆ setInitialProperty()

bool QQmlComponentPrivate::setInitialProperty ( QObject * component,
const QString & name,
const QVariant & value )

Definition at line 375 of file qqmlcomponent.cpp.

◆ typeDataProgress()

void QQmlComponentPrivate::typeDataProgress ( QQmlTypeData * ,
qreal p )
overridevirtual

Reimplemented from QQmlTypeData::TypeDataCallback.

Definition at line 291 of file qqmlcomponent.cpp.

◆ typeDataReady()

void QQmlComponentPrivate::typeDataReady ( QQmlTypeData * )
overridevirtual

Reimplemented from QQmlTypeData::TypeDataCallback.

Definition at line 277 of file qqmlcomponent.cpp.

◆ unsetRequiredPropertyToQQmlError()

QQmlError QQmlComponentPrivate::unsetRequiredPropertyToQQmlError ( const RequiredPropertyInfo & unsetRequiredProperty)
static

Definition at line 1828 of file qqmlcomponent.cpp.

Member Data Documentation

◆ compilationUnit

QQmlRefPointer<QV4::ExecutableCompilationUnit> QQmlComponentPrivate::compilationUnit

Definition at line 84 of file qqmlcomponent_p.h.

◆ creationContext

QQmlGuardedContextData QQmlComponentPrivate::creationContext

Definition at line 169 of file qqmlcomponent_p.h.

◆ engine

QQmlEngine* QQmlComponentPrivate::engine

Definition at line 168 of file qqmlcomponent_p.h.

◆ inlineComponentName

std::unique_ptr<QString> QQmlComponentPrivate::inlineComponentName

Definition at line 77 of file qqmlcomponent_p.h.

◆ loadHelper

QQmlRefPointer<LoadHelper> QQmlComponentPrivate::loadHelper

Definition at line 68 of file qqmlcomponent_p.h.

◆ progress

qreal QQmlComponentPrivate::progress

Definition at line 76 of file qqmlcomponent_p.h.

◆ start

int QQmlComponentPrivate::start

Definition at line 81 of file qqmlcomponent_p.h.

◆ state

ConstructionState QQmlComponentPrivate::state

Definition at line 158 of file qqmlcomponent_p.h.

◆ typeData

QQmlRefPointer<QQmlTypeData> QQmlComponentPrivate::typeData

Definition at line 67 of file qqmlcomponent_p.h.

◆ url

QUrl QQmlComponentPrivate::url

Definition at line 75 of file qqmlcomponent_p.h.


The documentation for this class was generated from the following files: