QQmlImports Class

The QQmlImports class encapsulates one QML document's import statements. \internal. More...

Header: #include <QQmlImports>

Public Types

flags ImportFlags

Public Functions

QTypeRevision addFileImport(QQmlImportDatabase *database, const QString &uri, const QString &prefix, QTypeRevision version, ImportFlags flags, quint16 precedence, QString *localQmldir, QList<QQmlError> *errors)
bool addInlineComponentImport(QQmlImportInstance *const importInstance, const QString &name, const QUrl importUrl, QQmlType containingType)
bool resolveType(const QHashedStringRef &type, QQmlType *type_return, QTypeRevision *version_return, QQmlImportNamespace **ns_return, QList<QQmlError> *errors = nullptr, QQmlType::RegistrationType registrationType = QQmlType::AnyRegistrationType, bool *typeRecursionDetected = nullptr) const
void setBaseUrl(const QUrl &url, const QString &urlString = QString())

Static Public Members

QStringList completeQmldirPaths(const QString &uri, const QStringList &basePaths, QTypeRevision version)

Detailed Description

Member Function Documentation

QTypeRevision QQmlImports::addFileImport(QQmlImportDatabase *database, const QString &uri, const QString &prefix, QTypeRevision version, ImportFlags flags, quint16 precedence, QString *localQmldir, QList<QQmlError> *errors)

\internal

Adds information to database such that subsequent calls to resolveType() will resolve types qualified by prefix by considering types found at the given uri.

The uri is either a directory (if importType is FileImport), or a URI resolved using paths added via addImportPath() (if importType is LibraryImport).

The prefix may be empty, in which case the import location is considered for unqualified types.

The base URL must already have been set with Import::setBaseUrl().

Optionally, the qmldir the import resolved to can be returned by providing the localQmldir parameter. Not all imports will have a local qmldir. If there is none, the localQmldir parameter won't be set.

Returns a valid QTypeRevision on success, and an invalid one on failure. In case of failure, the errors array will filled appropriately.

bool QQmlImports::addInlineComponentImport(QQmlImportInstance *const importInstance, const QString &name, const QUrl importUrl, QQmlType containingType)

\internal

[static] QStringList QQmlImports::completeQmldirPaths(const QString &uri, const QStringList &basePaths, QTypeRevision version)

Forms complete paths to a qmldir file, from a base URL, a module URI and version specification.

For example, QtQml.Models 2.0: - base/QtQml/Models.2.0/qmldir - base/QtQml.2.0/Models/qmldir - base/QtQml/Models.2/qmldir - base/QtQml.2/Models/qmldir - base/QtQml/Models/qmldir

bool QQmlImports::resolveType(const QHashedStringRef &type, QQmlType *type_return, QTypeRevision *version_return, QQmlImportNamespace **ns_return, QList<QQmlError> *errors = nullptr, QQmlType::RegistrationType registrationType = QQmlType::AnyRegistrationType, bool *typeRecursionDetected = nullptr) const

\internal

The given (namespace qualified) type is resolved to either

If any return pointer is 0, the corresponding search is not done.

See also addFileImport() and addLibraryImport.

void QQmlImports::setBaseUrl(const QUrl &url, const QString &urlString = QString())

Sets the base URL to be used for all relative file imports added.