QQmlAbstractUrlInterceptor Class

allows you to control QML file loading. More...

Header: #include <QQmlAbstractUrlInterceptor>
qmake: QT += qml

Public Types

enum DataType { QmlFile, JavaScriptFile, QmldirFile, UrlString }

Public Functions

QQmlAbstractUrlInterceptor()
virtual ~QQmlAbstractUrlInterceptor()
virtual QUrl intercept(const QUrl & url, DataType type) = 0

Detailed Description

allows you to control QML file loading.

QQmlAbstractUrlInterceptor is an interface which can be used to alter URLs before they are used by the QML engine. This is primarily useful for altering file urls into other file urls, such as selecting different graphical assets for the current platform.

Relative URLs are intercepted after being resolved against the file path of the current QML context. URL interception also occurs after setting the base path for a loaded QML file. This means that the content loaded for that QML file uses the intercepted URL, but inside the file the pre-intercepted URL is used for resolving relative paths. This allows for interception of .qml file loading without needing all paths (or local types) inside intercepted content to insert a different relative path.

Compared to setNetworkAccessManagerFactory, QQmlAbstractUrlInterceptor affects all URLs and paths, including local files and embedded resource files. QQmlAbstractUrlInterceptor is synchronous, and for asynchronous files must return a url with an asynchronous scheme (such as http or a custom scheme handled by your own custom QNetworkAccessManager). You can use a QQmlAbstractUrlInterceptor to change file URLs into networked URLs which are handled by your own custom QNetworkAccessManager.

To implement support for a custom networked scheme, see setNetworkAccessManagerFactory.

Member Type Documentation

enum QQmlAbstractUrlInterceptor::​DataType

Member Function Documentation

QQmlAbstractUrlInterceptor::​QQmlAbstractUrlInterceptor()

[virtual] QQmlAbstractUrlInterceptor::​~QQmlAbstractUrlInterceptor()

[pure virtual] QUrl QQmlAbstractUrlInterceptor::​intercept(const QUrl & url, DataType type)

A pure virtual function where you can intercept the url. The returned value is taken as the new value for the url. The type of url being intercepted is given by the type variable.

Your implementation of this function must be thread-safe, as it can be called from multiple threads at the same time.

© 2015 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.