Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
The QQmlEngine class provides an environment for instantiating QML components. More...
#include <qqmlengine.h>
Public Slots | |
void | retranslate () |
Refreshes all binding expressions that use strings marked for translation. | |
Public Slots inherited from QObject | |
void | deleteLater () |
\threadsafe | |
Signals | |
void | offlineStoragePathChanged () |
This signal is emitted when \l offlineStoragePath changes. | |
void | quit () |
This signal is emitted when the QML loaded by the engine would like to quit. | |
void | exit (int retCode) |
This signal is emitted when the QML loaded by the engine would like to exit from the event loop with the specified return code retCode. | |
void | warnings (const QList< QQmlError > &warnings) |
This signal is emitted when warnings messages are generated by QML. | |
Signals inherited from QJSEngine | |
void | uiLanguageChanged () |
Signals inherited from QObject | |
void | destroyed (QObject *=nullptr) |
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked. | |
void | objectNameChanged (const QString &objectName, QPrivateSignal) |
This signal is emitted after the object's name has been changed. | |
Public Member Functions | |
QQmlEngine (QObject *p=nullptr) | |
Create a new QQmlEngine with the given parent. | |
~QQmlEngine () override | |
Destroys the QQmlEngine. | |
QQmlContext * | rootContext () const |
Returns the engine's root context. | |
void | clearComponentCache () |
Clears the engine's internal component cache. | |
void | trimComponentCache () |
Trims the engine's internal component cache. | |
void | clearSingletons () |
Clears all singletons the engine owns. | |
QStringList | importPathList () const |
Returns the list of directories where the engine searches for installed modules in a URL-based directory structure. | |
void | setImportPathList (const QStringList &paths) |
Sets paths as the list of directories where the engine searches for installed modules in a URL-based directory structure. | |
void | addImportPath (const QString &dir) |
Adds path as a directory where the engine searches for installed modules in a URL-based directory structure. | |
QStringList | pluginPathList () const |
Returns the list of directories where the engine searches for native plugins for imported modules (referenced in the qmldir file). | |
void | setPluginPathList (const QStringList &paths) |
Sets the list of directories where the engine searches for native plugins for imported modules (referenced in the qmldir file) to paths. | |
void | addPluginPath (const QString &dir) |
Adds path as a directory where the engine searches for native plugins for imported modules (referenced in the qmldir file). | |
void | addUrlInterceptor (QQmlAbstractUrlInterceptor *urlInterceptor) |
Adds a urlInterceptor to be used when resolving URLs in QML. | |
void | removeUrlInterceptor (QQmlAbstractUrlInterceptor *urlInterceptor) |
Remove a urlInterceptor that was previously added using \l addUrlInterceptor. | |
QList< QQmlAbstractUrlInterceptor * > | urlInterceptors () const |
Returns the list of currently active URL interceptors. | |
QUrl | interceptUrl (const QUrl &url, QQmlAbstractUrlInterceptor::DataType type) const |
Run the current URL interceptors on the given url of the given type and return the result. | |
void | addImageProvider (const QString &id, QQmlImageProviderBase *) |
Sets the provider to use for images requested via the image: url scheme, with host providerId. | |
QQmlImageProviderBase * | imageProvider (const QString &id) const |
Returns the image provider set for providerId if found; otherwise returns \nullptr. | |
void | removeImageProvider (const QString &id) |
Removes the image provider for providerId. | |
void | setIncubationController (QQmlIncubationController *) |
Sets the engine's incubation controller. | |
QQmlIncubationController * | incubationController () const |
Returns the currently set incubation controller, or 0 if no controller has been set. | |
void | setOfflineStoragePath (const QString &dir) |
QString | offlineStoragePath () const |
QString | offlineStorageDatabaseFilePath (const QString &databaseName) const |
Returns the file path where a \l{QtQuick.LocalStorage}{Local Storage} database with the identifier databaseName is (or would be) located. | |
QUrl | baseUrl () const |
Return the base URL for this engine. | |
void | setBaseUrl (const QUrl &) |
Set the base URL for this engine to url. | |
bool | outputWarningsToStandardError () const |
Returns true if warning messages will be output to stderr in addition to being emitted by the warnings() signal, otherwise false. | |
void | setOutputWarningsToStandardError (bool) |
Set whether warning messages will be output to stderr to enabled. | |
void | markCurrentFunctionAsTranslationBinding () |
template<typename T > | |
T | singletonInstance (int qmlTypeId) |
\qmlproperty string Qt::uiLanguage | |
template<typename T > | |
T | singletonInstance (QAnyStringView moduleName, QAnyStringView typeName) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns the instance of a singleton type named typeName from the module specified by uri. | |
void | captureProperty (QObject *object, const QMetaProperty &property) const |
template<> | |
Q_QML_EXPORT QJSValue | singletonInstance (int qmlTypeId) |
template<> | |
Q_QML_EXPORT QJSValue | singletonInstance (QAnyStringView uri, QAnyStringView typeName) |
template<> | |
QJSValue | singletonInstance (int qmlTypeId) |
template<> | |
QJSValue | singletonInstance (QAnyStringView uri, QAnyStringView typeName) |
template<> | |
QJSValue | singletonInstance (int qmlTypeId) |
template<> | |
QJSValue | singletonInstance (QAnyStringView uri, QAnyStringView typeName) |
Public Member Functions inherited from QJSEngine | |
QJSEngine () | |
Constructs a QJSEngine object. | |
QJSEngine (QObject *parent) | |
Constructs a QJSEngine object with the given parent. | |
~QJSEngine () override | |
Destroys this QJSEngine. | |
QJSValue | globalObject () const |
Returns this engine's Global Object. | |
QJSValue | evaluate (const QString &program, const QString &fileName=QString(), int lineNumber=1, QStringList *exceptionStackTrace=nullptr) |
Evaluates program, using lineNumber as the base line number, and returns the result of the evaluation. | |
QJSValue | importModule (const QString &fileName) |
Imports the module located at fileName and returns a module namespace object that contains all exported variables, constants and functions as properties. | |
bool | registerModule (const QString &moduleName, const QJSValue &value) |
Registers a QJSValue to serve as a module. | |
QJSValue | newObject () |
Creates a JavaScript object of class Object. | |
QJSValue | newSymbol (const QString &name) |
QJSValue | newArray (uint length=0) |
Creates a JavaScript object of class Array with the given length. | |
QJSValue | newQObject (QObject *object) |
Creates a JavaScript object that wraps the given QObject object, using JavaScriptOwnership. | |
QJSValue | newQMetaObject (const QMetaObject *metaObject) |
template<typename T > | |
QJSValue | newQMetaObject () |
QJSValue | newErrorObject (QJSValue::ErrorType errorType, const QString &message=QString()) |
template<typename T > | |
QJSValue | toScriptValue (const T &value) |
Creates a QJSValue with the given value. | |
template<typename T > | |
QJSManagedValue | toManagedValue (const T &value) |
Creates a QJSManagedValue with the given value. | |
template<typename T > | |
QJSPrimitiveValue | toPrimitiveValue (const T &value) |
Creates a QJSPrimitiveValue with the given value. | |
template<typename T > | |
T | fromScriptValue (const QJSValue &value) |
Returns the given value converted to the template type {T}. | |
template<typename T > | |
T | fromManagedValue (const QJSManagedValue &value) |
Returns the given value converted to the template type {T}. | |
template<typename T > | |
T | fromPrimitiveValue (const QJSPrimitiveValue &value) |
Returns the given value converted to the template type {T}. | |
template<typename T > | |
T | fromVariant (const QVariant &value) |
Returns the given value converted to the template type {T}. | |
template<typename From , typename To > | |
To | coerceValue (const From &from) |
Returns the given from converted to the template type {To}. | |
void | collectGarbage () |
Runs the garbage collector. | |
void | installExtensions (Extensions extensions, const QJSValue &object=QJSValue()) |
void | setInterrupted (bool interrupted) |
bool | isInterrupted () const |
QV4::ExecutionEngine * | handle () const |
void | throwError (const QString &message) |
Throws a run-time error (exception) with the given message. | |
void | throwError (QJSValue::ErrorType errorType, const QString &message=QString()) |
void | throwError (const QJSValue &error) |
bool | hasError () const |
Returns true if the last JavaScript execution resulted in an exception or if throwError() was called. | |
QJSValue | catchError () |
If an exception is currently pending, catches it and returns it as a QJSValue. | |
QString | uiLanguage () const |
void | setUiLanguage (const QString &language) |
Public Member Functions inherited from QObject | |
Q_INVOKABLE | QObject (QObject *parent=nullptr) |
Constructs an object with parent object parent. | |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. | |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
Filters events if this object has been installed as an event filter for the watched object. | |
QString | objectName () const |
Q_WEAK_OVERLOAD void | setObjectName (const QString &name) |
Sets the object's name to name. | |
void | setObjectName (QAnyStringView name) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QBindable< QString > | bindableObjectName () |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false . | |
bool | isWindowType () const |
Returns true if the object is a window; otherwise returns false . | |
bool | isQuickItemType () const |
Returns true if the object is a QQuickItem; otherwise returns false . | |
bool | signalsBlocked () const noexcept |
Returns true if signals are blocked; otherwise returns false . | |
bool | blockSignals (bool b) noexcept |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). | |
QThread * | thread () const |
Returns the thread in which the object lives. | |
bool | moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL) |
Changes the thread affinity for this object and its children and returns true on success. | |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds. | |
int | startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer) |
void | killTimer (int id) |
Kills the timer with timer identifier, id. | |
void | killTimer (Qt::TimerId id) |
template<typename T > | |
T | findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object. | |
template<typename T > | |
QList< T > | findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. | |
template<typename T > | |
T | findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<typename T > | |
QList< T > | findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
const QObjectList & | children () const |
Returns a list of child objects. | |
void | setParent (QObject *parent) |
Makes the object a child of parent. | |
void | installEventFilter (QObject *filterObj) |
Installs an event filter filterObj on this object. | |
void | removeEventFilter (QObject *obj) |
Removes an event filter object obj from this object. | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const |
bool | disconnect (const QObject *receiver, const char *member=nullptr) const |
void | dumpObjectTree () const |
Dumps a tree of children to the debug output. | |
void | dumpObjectInfo () const |
Dumps information about signal connections, etc. | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. | |
bool | setProperty (const char *name, QVariant &&value) |
QVariant | property (const char *name) const |
Returns the value of the object's name property. | |
QList< QByteArray > | dynamicPropertyNames () const |
QBindingStorage * | bindingStorage () |
const QBindingStorage * | bindingStorage () const |
QObject * | parent () const |
Returns a pointer to the parent object. | |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false . | |
Static Public Member Functions | |
static QQmlContext * | contextForObject (const QObject *) |
Returns the QQmlContext for the object, or nullptr if no context has been set. | |
static void | setContextForObject (QObject *, QQmlContext *) |
Sets the QQmlContext for the object to context. | |
Static Public Member Functions inherited from QJSEngine | |
static void | setObjectOwnership (QObject *, ObjectOwnership) |
Sets the ownership of object. | |
static ObjectOwnership | objectOwnership (QObject *) |
Returns the ownership of object. | |
Static Public Member Functions inherited from QObject | |
static QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
\threadsafe | |
static QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
template<typename Func1 , typename Func2 > | |
static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection) |
template<typename Func1 , typename Func2 > | |
static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
\threadsafe | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static bool | disconnect (const QMetaObject::Connection &) |
Disconnect a connection. | |
template<typename Func1 , typename Func2 > | |
static bool | disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot) |
template<typename Func1 > | |
static bool | disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero) |
Protected Member Functions | |
QQmlEngine (QQmlEnginePrivate &dd, QObject *p) | |
bool | event (QEvent *) override |
\reimp | |
Protected Member Functions inherited from QJSEngine | |
QJSEngine (QJSEnginePrivate &dd, QObject *parent=nullptr) | |
Protected Member Functions inherited from QObject | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr. | |
int | senderSignalIndex () const |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. | |
bool | isSignalConnected (const QMetaMethod &signal) const |
virtual void | timerEvent (QTimerEvent *event) |
This event handler can be reimplemented in a subclass to receive timer events for the object. | |
virtual void | childEvent (QChildEvent *event) |
This event handler can be reimplemented in a subclass to receive child events. | |
virtual void | customEvent (QEvent *event) |
This event handler can be reimplemented in a subclass to receive custom events. | |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
QObject (QObjectPrivate &dd, QObject *parent=nullptr) | |
Properties | |
QString | offlineStoragePath |
the directory for storing offline user data | |
Properties inherited from QJSEngine | |
QString | uiLanguage |
the language to be used for translating user interface strings | |
Properties inherited from QObject | |
QString | objectName |
the name of this object | |
Related Symbols | |
(Note that these are not member symbols.) | |
void | qmlRegisterModuleImport (const char *uri, int moduleMajor, const char *import, int importMajor, int importMinor) |
Registers a qmldir-import for module uri of major version moduleMajor. | |
void | qmlUnregisterModuleImport (const char *uri, int moduleMajor, const char *import, int importMajor, int importMinor) |
Removes a module import previously registered with qmlRegisterModuleImport() | |
QQmlEngine * | qmlEngine (const QObject *object) |
Returns the QQmlEngine associated with object, if any. | |
QQmlContext * | qmlContext (const QObject *object) |
Returns the QQmlContext associated with object, if any. | |
Related Symbols inherited from QJSEngine | |
QJSEngine * | qjsEngine (const QObject *object) |
Related Symbols inherited from QObject | |
template< class T > T | qobject_cast (const QObject *object) |
Returns the given object cast to type T if the object is of type T (or of a subclass); otherwise returns \nullptr. | |
template< typename T > T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
template< typename T > QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QObjectList | |
\macro Q_CLASSINFO(Name, Value) | |
Additional Inherited Members | |
Public Types inherited from QJSEngine | |
enum | ObjectOwnership { CppOwnership , JavaScriptOwnership } |
ObjectOwnership controls whether or not the JavaScript memory manager automatically destroys the QObject when the corresponding JavaScript object is garbage collected by the engine. More... | |
enum | Extension { TranslationExtension = 0x1 , ConsoleExtension = 0x2 , GarbageCollectionExtension = 0x4 , AllExtensions = 0xffffffff } |
This enum is used to specify extensions to be installed via \l installExtensions(). More... | |
Protected Attributes inherited from QObject | |
QScopedPointer< QObjectData > | d_ptr |
The QQmlEngine class provides an environment for instantiating QML components.
A QQmlEngine is used to manage \l{QQmlComponent}{components} and objects created from them and execute their bindings and functions. QQmlEngine also inherits from \l{QJSEngine} which allows seamless integration between your QML components and JavaScript code.
Each QML component is instantiated in a QQmlContext. In QML, contexts are arranged hierarchically and this hierarchy is managed by the QQmlEngine. By default, components are instantiated in the \l {QQmlEngine::rootContext()}{root context}.
Definition at line 56 of file qqmlengine.h.
Create a new QQmlEngine with the given parent.
Definition at line 507 of file qqmlengine.cpp.
|
override |
Destroys the QQmlEngine.
Any QQmlContext's created on this engine will be invalidated, but not destroyed (unless they are parented to the QQmlEngine object).
See ~QJSEngine() for details on cleaning up the JS engine.
Definition at line 534 of file qqmlengine.cpp.
|
protected |
Definition at line 518 of file qqmlengine.cpp.
void QQmlEngine::addImageProvider | ( | const QString & | providerId, |
QQmlImageProviderBase * | provider ) |
Sets the provider to use for images requested via the image: url scheme, with host providerId.
The QQmlEngine takes ownership of provider.
Image providers enable support for pixmap and threaded image requests. See the QQuickImageProvider documentation for details on implementing and using image providers.
All required image providers should be added to the engine before any QML sources files are loaded.
Definition at line 845 of file qqmlengine.cpp.
Adds path as a directory where the engine searches for installed modules in a URL-based directory structure.
The path may be a local filesystem directory, a \l {The Qt Resource System}{Qt Resource} path ({
:/imports}), a \l {The Qt Resource System}{Qt Resource} url ({qrc:/imports}
) or a URL.
The path will be converted into canonical form before it is added to the import path list.
The newly added path will be first in the importPathList().
{See also} \l setImportPathList(), \l {QML Modules}, and \l [QtQml] {QML Import Path}
Definition at line 1622 of file qqmlengine.cpp.
Adds path as a directory where the engine searches for native plugins for imported modules (referenced in the qmldir
file).
By default, the list contains only ., i.e. the engine searches in the directory of the
qmldir
file itself.
The newly added path will be first in the pluginPathList().
Definition at line 1679 of file qqmlengine.cpp.
void QQmlEngine::addUrlInterceptor | ( | QQmlAbstractUrlInterceptor * | urlInterceptor | ) |
Adds a urlInterceptor to be used when resolving URLs in QML.
This also applies to URLs used for loading script files and QML types. The URL interceptors should not be modifed while the engine is loading files, or URL selection may be inconsistent. Multiple URL interceptors, when given, will be called in the order they were added for each URL.
QQmlEngine does not take ownership of the interceptor and won't delete it.
Definition at line 710 of file qqmlengine.cpp.
QUrl QQmlEngine::baseUrl | ( | ) | const |
Return the base URL for this engine.
The base URL is only used to resolve components when a relative URL is passed to the QQmlComponent constructor.
If a base URL has not been explicitly set, this method returns the application's current working directory.
Definition at line 890 of file qqmlengine.cpp.
void QQmlEngine::captureProperty | ( | QObject * | object, |
const QMetaProperty & | property ) const |
Capture the given property as part of a binding.
Definition at line 985 of file qqmlengine.cpp.
void QQmlEngine::clearComponentCache | ( | ) |
Clears the engine's internal component cache.
This function causes the property metadata of most components previously loaded by the engine to be destroyed. It does so by dropping unreferenced components from the engine's component cache. It does not drop components that are still referenced since that would almost certainly lead to crashes further down the line.
If no components are referenced, this function returns the engine to a state where it does not contain any loaded component data. This may be useful in order to reload a smaller subset of the previous component set, or to load a new version of a previously loaded component.
Once the component cache has been cleared, components must be loaded before any new objects can be created.
As a general rule of thumb, make sure that no objects created from QML components are alive when you clear the component cache.
Definition at line 609 of file qqmlengine.cpp.
void QQmlEngine::clearSingletons | ( | ) |
Clears all singletons the engine owns.
This function drops all singleton instances, deleting any QObjects owned by the engine among them. This is useful to make sure that no QML-created objects are left before calling clearComponentCache().
QML properties holding QObject-based singleton instances become null if the engine owns the singleton or retain their value if the engine doesn't own it. The singletons are not automatically re-created by accessing existing QML-created objects. Only when new components are instantiated, the singletons are re-created.
Definition at line 662 of file qqmlengine.cpp.
|
static |
Returns the QQmlContext for the object, or nullptr if no context has been set.
When the QQmlEngine instantiates a QObject, an internal context is assigned to it automatically. Such internal contexts are read-only. You cannot set context properties on them.
Definition at line 1115 of file qqmlengine.cpp.
|
overrideprotectedvirtual |
|
signal |
This signal is emitted when the QML loaded by the engine would like to exit from the event loop with the specified return code retCode.
QQmlImageProviderBase * QQmlEngine::imageProvider | ( | const QString & | providerId | ) | const |
Returns the image provider set for providerId if found; otherwise returns \nullptr.
Definition at line 859 of file qqmlengine.cpp.
QStringList QQmlEngine::importPathList | ( | ) | const |
Returns the list of directories where the engine searches for installed modules in a URL-based directory structure.
For example, if /opt/MyApp/lib/imports
is in the path, then QML that imports com.mycompany.Feature
will cause the QQmlEngine to look in /opt/MyApp/lib/imports/com/mycompany/Feature/
for the components provided by that module. A qmldir
file is required for defining the type version mapping and possibly QML extensions plugins.
By default, this list contains the paths mentioned in \l {QML Import Path}.
Definition at line 1643 of file qqmlengine.cpp.
QQmlIncubationController * QQmlEngine::incubationController | ( | ) | const |
Returns the currently set incubation controller, or 0 if no controller has been set.
Definition at line 87 of file qqmlincubator.cpp.
QUrl QQmlEngine::interceptUrl | ( | const QUrl & | url, |
QQmlAbstractUrlInterceptor::DataType | type ) const |
Run the current URL interceptors on the given url of the given type and return the result.
Definition at line 734 of file qqmlengine.cpp.
void QQmlEngine::markCurrentFunctionAsTranslationBinding | ( | ) |
LanguageChange
events. That is a more general mechanism which also works when the class is used in a non-QML context, and has slightly less overhead. However, using markCurrentFunctionAsTranslationBinding
can be acceptable when the class is already closely tied to the QML engine. For more details, see \l {Prepare for Dynamic Language Changes}Definition at line 973 of file qqmlengine.cpp.
Returns the file path where a \l{QtQuick.LocalStorage}{Local Storage} database with the identifier databaseName is (or would be) located.
Definition at line 1802 of file qqmlengine.cpp.
QString QQmlEngine::offlineStoragePath | ( | ) | const |
Definition at line 1777 of file qqmlengine.cpp.
|
signal |
This signal is emitted when \l offlineStoragePath changes.
bool QQmlEngine::outputWarningsToStandardError | ( | ) | const |
Returns true if warning messages will be output to stderr in addition to being emitted by the warnings() signal, otherwise false.
The default value is true.
Definition at line 919 of file qqmlengine.cpp.
QStringList QQmlEngine::pluginPathList | ( | ) | const |
Returns the list of directories where the engine searches for native plugins for imported modules (referenced in the qmldir
file).
By default, the list contains only ., i.e. the engine searches in the directory of the
qmldir
file itself.
Definition at line 1694 of file qqmlengine.cpp.
|
signal |
This signal is emitted when the QML loaded by the engine would like to quit.
Removes the image provider for providerId.
Definition at line 872 of file qqmlengine.cpp.
void QQmlEngine::removeUrlInterceptor | ( | QQmlAbstractUrlInterceptor * | urlInterceptor | ) |
Remove a urlInterceptor that was previously added using \l addUrlInterceptor.
The URL interceptors should not be modifed while the engine is loading files, or URL selection may be inconsistent.
This does not delete the interceptor, but merely removes it from the engine. You can re-use it on the same or a different engine afterwards.
Definition at line 724 of file qqmlengine.cpp.
|
slot |
Refreshes all binding expressions that use strings marked for translation.
Call this function after you have installed a new translator with QCoreApplication::installTranslator, to ensure that your user-interface shows up-to-date translations.
Definition at line 1099 of file qqmlengine.cpp.
QQmlContext * QQmlEngine::rootContext | ( | ) | const |
Returns the engine's root context.
The root context is automatically created by the QQmlEngine. Data that should be available to all QML component instances instantiated by the engine should be put in the root context.
Additional data that should only be available to a subset of component instances should be added to sub-contexts parented to the root context.
Definition at line 679 of file qqmlengine.cpp.
Set the base URL for this engine to url.
Definition at line 907 of file qqmlengine.cpp.
|
static |
Sets the QQmlContext for the object to context.
If the object already has a context, a warning is output, but the context is not changed.
When the QQmlEngine instantiates a QObject, the context is set automatically.
Definition at line 1135 of file qqmlengine.cpp.
void QQmlEngine::setImportPathList | ( | const QStringList & | paths | ) |
Sets paths as the list of directories where the engine searches for installed modules in a URL-based directory structure.
By default, this list contains the paths mentioned in \l {QML Import Path}.
Definition at line 1661 of file qqmlengine.cpp.
void QQmlEngine::setIncubationController | ( | QQmlIncubationController * | controller | ) |
Sets the engine's incubation controller.
The engine can only have one active controller and it does not take ownership of it.
Definition at line 73 of file qqmlincubator.cpp.
Definition at line 1768 of file qqmlengine.cpp.
void QQmlEngine::setOutputWarningsToStandardError | ( | bool | enabled | ) |
Set whether warning messages will be output to stderr to enabled.
If enabled is true, any warning messages generated by QML will be output to stderr and emitted by the warnings() signal. If enabled is false, only the warnings() signal will be emitted. This allows applications to handle warning output themselves.
The default value is true.
Definition at line 935 of file qqmlengine.cpp.
void QQmlEngine::setPluginPathList | ( | const QStringList & | paths | ) |
Sets the list of directories where the engine searches for native plugins for imported modules (referenced in the qmldir
file) to paths.
By default, the list contains only ., i.e. the engine searches in the directory of the
qmldir
file itself.
Definition at line 1710 of file qqmlengine.cpp.
QJSValue QQmlEngine::singletonInstance | ( | int | qmlTypeId | ) |
Definition at line 1041 of file qqmlengine.cpp.
QJSValue QQmlEngine::singletonInstance | ( | int | qmlTypeId | ) |
Definition at line 1041 of file qqmlengine.cpp.
T QQmlEngine::singletonInstance | ( | int | qmlTypeId | ) |
\qmlproperty string Qt::uiLanguage
The uiLanguage holds the name of the language to be used for user interface string translations. It is exposed in C++ as QQmlEngine::uiLanguage property.
You can set the value freely and use it in bindings. It is recommended to set it after installing translators in your application. By convention, an empty string means no translation from the language used in the source code is intended to occur.
If you're using QQmlApplicationEngine and the value changes, QQmlEngine::retranslate() will be called.
Returns the instance of a singleton type that was registered under qmlTypeId.
The template argument T may be either QJSValue or a pointer to a QObject-derived type and depends on how the singleton was registered. If no instance of T has been created yet, it is created now. If qmlTypeId does not represent a valid singleton type, either a default constructed QJSValue or a nullptr
is returned.
QObject* example:
\codeline
\codeline
QJSValue example:
\codeline
It is recommended to store the QML type id, e.g. as a static member in the singleton class. The lookup via qmlTypeId() is costly.
Definition at line 164 of file qqmlengine.h.
Q_QML_EXPORT QJSValue QQmlEngine::singletonInstance | ( | int | qmlTypeId | ) |
T QQmlEngine::singletonInstance | ( | QAnyStringView | uri, |
QAnyStringView | typeName ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns the instance of a singleton type named typeName from the module specified by uri.
This method can be used as an alternative to calling qmlTypeId followed by the id based overload of singletonInstance. This is convenient when one only needs to do a one time setup of a singleton; if repeated access to the singleton is required, caching its typeId will allow faster subsequent access via the \l {QQmlEngine::singletonInstance(int qmlTypeId)}{type-id based overload}.
The template argument T may be either QJSValue or a pointer to a QObject-derived type and depends on how the singleton was registered. If no instance of T has been created yet, it is created now. If typeName does not represent a valid singleton type, either a default constructed QJSValue or a nullptr
is returned.
Definition at line 172 of file qqmlengine.h.
QJSValue QQmlEngine::singletonInstance | ( | QAnyStringView | uri, |
QAnyStringView | typeName ) |
Definition at line 1076 of file qqmlengine.cpp.
QJSValue QQmlEngine::singletonInstance | ( | QAnyStringView | uri, |
QAnyStringView | typeName ) |
Definition at line 1076 of file qqmlengine.cpp.
Q_QML_EXPORT QJSValue QQmlEngine::singletonInstance | ( | QAnyStringView | uri, |
QAnyStringView | typeName ) |
void QQmlEngine::trimComponentCache | ( | ) |
Trims the engine's internal component cache.
This function causes the property metadata of any loaded components which are not currently in use to be destroyed.
A component is considered to be in use if there are any extant instances of the component itself, any instances of other components that use the component, or any objects instantiated by any of those components.
Definition at line 640 of file qqmlengine.cpp.
QList< QQmlAbstractUrlInterceptor * > QQmlEngine::urlInterceptors | ( | ) | const |
Returns the list of currently active URL interceptors.
Definition at line 746 of file qqmlengine.cpp.
This signal is emitted when warnings messages are generated by QML.
|
related |
Returns the QQmlContext associated with object, if any.
This is equivalent to QQmlEngine::contextForObject(object).
{#include <QtQml>} to use this function.
|
related |
Returns the QQmlEngine associated with object, if any.
This is equivalent to QQmlEngine::contextForObject(object)->engine(), but more efficient.
{#include <QtQml>} to use this function.
|
related |
Registers a qmldir-import for module uri of major version moduleMajor.
This has the same effect as an import
statement in a qmldir file: Whenever uri of version moduleMajor is imported, import of version importMajor. importMinor is automatically imported, too. If importMajor is \l QQmlModuleImportLatest the latest version available of that module is imported, and importMinor does not matter. If importMinor is \l QQmlModuleImportLatest the latest minor version of a importMajor is chosen. If importMajor is \l QQmlModuleImportAuto the version of import is version of uri being imported, and importMinor does not matter. If moduleMajor is \l QQmlModuleImportModuleAny the module import is applied for any major version of uri. For example, you may specify that whenever any version of MyModule is imported, the latest version of MyOtherModule should be imported. Then, the following call would be appropriate:
Or, you may specify that whenever major version 5 of "MyModule" is imported, then version 3.14 of "MyOtherModule" should be imported:
Finally, if you always want the same version of "MyOtherModule" to be imported whenever "MyModule" is imported, specify the following:
|
related |
Removes a module import previously registered with qmlRegisterModuleImport()
Calling this function makes sure that import of version {importMajor}.{importMinor} is not automatically imported anymore when uri of version moduleMajor is. The version resolution works the same way as with \l qmlRegisterModuleImport().
|
readwrite |
the directory for storing offline user data
Returns the directory where SQL and other offline storage is placed.
The SQL databases created with openDatabaseSync()
are stored here.
The default is QML/OfflineStorage in the platform-standard user application data directory.
Note that the path may not currently exist on the filesystem, so callers wanting to create new files at this location should create it first - see QDir::mkpath().
Definition at line 58 of file qqmlengine.h.