KDeclarative::QmlObject

#include <KDeclarative/QmlObject>

Inheritance diagram for KDeclarative::QmlObject:

Properties

bool initializationDelayed
 
QObject rootObject
 
QUrl source
 
QQmlComponent::Status status
 
QString translationDomain
 
- Properties inherited from QObject
 objectName
 

Signals

void finished ()
 
void statusChanged (QQmlComponent::Status)
 

Public Slots

void completeInitialization (const QVariantHash &initialProperties=QVariantHash())
 

Public Member Functions

 QmlObject (QObject *parent=nullptr)
 
 QmlObject (QQmlEngine *engine, QObject *parent=nullptr)
 
 QmlObject (QQmlEngine *engine, QQmlContext *rootContext, QObject *parent=nullptr)
 
QObjectcreateObjectFromComponent (QQmlComponent *component, QQmlContext *context=nullptr, const QVariantHash &initialProperties=QVariantHash())
 
QObjectcreateObjectFromSource (const QUrl &source, QQmlContext *context=nullptr, const QVariantHash &initialProperties=QVariantHash())
 
QQmlEngineengine ()
 
bool isInitializationDelayed () const
 
void loadPackage (const QString &packageName)
 
QQmlComponentmainComponent () const
 
KPackage::Package package () const
 
QQmlContextrootContext () const
 
QObjectrootObject () const
 
void setInitializationDelayed (const bool delay)
 
void setPackage (const KPackage::Package &package)
 
void setSource (const QUrl &source)
 
void setTranslationDomain (const QString &translationDomain)
 
QUrl source () const
 
QQmlComponent::Status status () const
 
QString translationDomain () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Protected Member Functions

 QmlObject (QQmlEngine *engine, QQmlContext *rootContext, QmlObject *obj, QObject *parent=nullptr)
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Public Attributes inherited from QObject
typedef QObjectList
 

Detailed Description

An object that instantiates an entire QML context, with its own declarative engine.

Author
Marco Martin [email protected][email protected]kde.[email protected]org

KDeclarative::QmlObject provides a class to conveniently use QML based declarative user interfaces inside Plasma widgets. A QmlObject corresponds to one QML file (which can include others). It will have its own QQmlEngine with a single root object, described in the QML file.

Definition at line 51 of file qmlobject.h.

Constructor & Destructor Documentation

KDeclarative::QmlObject::QmlObject ( QObject parent = nullptr)
explicit

Constructs a new QmlObject.

Parameters
parentthe parent of this object

Definition at line 142 of file qmlobject.cpp.

KDeclarative::QmlObject::QmlObject ( QQmlEngine engine,
QObject parent = nullptr 
)
explicit

Constructs a new QmlObject.

Parameters
enginea QQmlEngine we want to use
parentthe parent of this object

Definition at line 157 of file qmlobject.cpp.

KDeclarative::QmlObject::QmlObject ( QQmlEngine engine,
QQmlContext rootContext,
QObject parent = nullptr 
)
explicit

Constructs a new QmlObject.

Parameters
enginethe QQmlEngine to use
rootContextthe root context to use for object creation
parentthe parent of this object

Definition at line 163 of file qmlobject.cpp.

KDeclarative::QmlObject::QmlObject ( QQmlEngine engine,
QQmlContext rootContext,
QmlObject obj,
QObject parent = nullptr 
)
explicitprotected

Constructs a new QmlObject.

Parameters
enginea QQmlEngine we want to use
rootContextthe root context we want to use for objects creation
objsetupEngine is called when this is set to nullptr. This way the creator can influence if the engine should be initialized or not in case it is shared between multiple objects (such as QmlObjectSharedEngine)
parentthe parent of this object
Since
5.45

Definition at line 169 of file qmlobject.cpp.

Member Function Documentation

void KDeclarative::QmlObject::completeInitialization ( const QVariantHash &  initialProperties = QVariantHash())
slot

Finishes the process of initialization.

If isInitializationDelayed() is false, calling this will have no effect.

Parameters
initialPropertiesoptional properties that will be set on the object when created (and before Component.onCompleted gets emitted

Definition at line 302 of file qmlobject.cpp.

QObject * KDeclarative::QmlObject::createObjectFromComponent ( QQmlComponent component,
QQmlContext context = nullptr,
const QVariantHash &  initialProperties = QVariantHash() 
)

Creates and returns an object based on the provided QQmlComponent with the same QQmlEngine and the same root context as the admin object, that will be the parent of the newly created object.

Parameters
componentthe component we want to instantiate
contextThe QQmlContext in which we will create the object, if 0 it will use the engine's root context
initialPropertiesoptional properties that will be set on the object when created (and before Component.onCompleted gets emitted

Definition at line 343 of file qmlobject.cpp.

QObject * KDeclarative::QmlObject::createObjectFromSource ( const QUrl source,
QQmlContext context = nullptr,
const QVariantHash &  initialProperties = QVariantHash() 
)

Creates and returns an object based on the provided url to a Qml file with the same QQmlEngine and the same root context as the main object, that will be the parent of the newly created object.

Parameters
sourceurl where the QML file is located
contextThe QQmlContext in which we will create the object, if 0 it will use the engine's root context
initialPropertiesoptional properties that will be set on the object when created (and before Component.onCompleted gets emitted

Definition at line 335 of file qmlobject.cpp.

QQmlEngine * KDeclarative::QmlObject::engine ( )
Returns
the declarative engine that runs the qml file assigned to this widget.

Definition at line 251 of file qmlobject.cpp.

void KDeclarative::QmlObject::finished ( )
signal

Emitted when the parsing and execution of the QML file is terminated.

bool KDeclarative::QmlObject::isInitializationDelayed ( ) const
Returns
true if the initialization of the QML file will be delayed at the end of the event loop

Definition at line 246 of file qmlobject.cpp.

void KDeclarative::QmlObject::loadPackage ( const QString packageName)

Load the package called packageName, then loads the mainscript file for that package.

Parameters
packageNamethe plugin name of the package

Definition at line 223 of file qmlobject.cpp.

QQmlComponent * KDeclarative::QmlObject::mainComponent ( ) const
Returns
the main QQmlComponent of the engine

Definition at line 265 of file qmlobject.cpp.

KPackage::Package KDeclarative::QmlObject::package ( ) const
Returns
the optional package, if any

Definition at line 236 of file qmlobject.cpp.

QQmlContext * KDeclarative::QmlObject::rootContext ( ) const

The components's creation context.

Since
5.11

Definition at line 270 of file qmlobject.cpp.

QObject* KDeclarative::QmlObject::rootObject ( ) const
Returns
the root object of the declarative object tree
void KDeclarative::QmlObject::setInitializationDelayed ( const bool  delay)

Sets whether the execution of the QML file has to be delayed later in the event loop.

It has to be called before setQmlPath(). In this case it will be possible to assign new objects in the main engine context before the main component gets initialized. In that case it will be possible to access it immediately from the QML code. The initialization will either be completed automatically asynchronously or explicitly by calling completeInitialization()

Parameters
delayif true the initialization of the QML file will be delayed at the end of the event loop

Definition at line 241 of file qmlobject.cpp.

void KDeclarative::QmlObject::setPackage ( const KPackage::Package package)

Sets a package, then loads the mainscript file for that package.

Parameters
packagethe package we want to use to provide QML files to this QML object

Definition at line 230 of file qmlobject.cpp.

void KDeclarative::QmlObject::setSource ( const QUrl source)

Sets the path of the QML file to parse and execute.

Parameters
paththe absolute path of a QML file

Definition at line 212 of file qmlobject.cpp.

void KDeclarative::QmlObject::setTranslationDomain ( const QString translationDomain)

Call this method before calling setupBindings to install a translation domain for all i18n global functions.

If a translation domain is set all i18n calls delegate to the matching i18nd calls with the provided translation domain.

The translationDomain affects all i18n calls including those from imports. Because of that modules intended to be used as imports should prefer the i18nd variants and set the translation domain explicitly in each call.

This method is only required if your declarative usage is inside a library. If it's in an application there is no need to set the translation domain as the application's domain can be used.

Parameters
translationDomainThe translation domain to be used for i18n calls.
Since
5.0

Definition at line 202 of file qmlobject.cpp.

QUrl KDeclarative::QmlObject::source ( ) const
Returns
the absolute path of the current QML file
QQmlComponent::Status KDeclarative::QmlObject::status ( ) const

The component's current status.

Since
5.11
QString KDeclarative::QmlObject::translationDomain ( ) const
Returns
the translation domain for the i18n calls done in this QML engine
Since
5.0

The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun Jul 5 2020 22:38:42 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.