QQmlFile Class

The QQmlFile class provides static utility methods to categorize URLs. More...

Header: #include <QQmlFile>
CMake: find_package(Qt6 REQUIRED COMPONENTS Qml)
target_link_libraries(mytarget PRIVATE Qt6::Qml)
qmake: QT += qml

Static Public Members

bool isLocalFile(const QString &url)
bool isLocalFile(const QUrl &url)
QString urlToLocalFileOrQrc(const QString &url)
QString urlToLocalFileOrQrc(const QUrl &url)

Detailed Description

QQmlFile provides some static utility methods to categorize URLs and file names the way QQmlEngine does when loading content from them.

Member Function Documentation

[static] bool QQmlFile::isLocalFile(const QString &url)

Returns true if url is a local file that can be opened with QFile. Otherwise returns false. Local file urls have either a qrc: or file: scheme.

Note: On Android, urls with assets: or content: scheme are also considered local files.

[static] bool QQmlFile::isLocalFile(const QUrl &url)

Returns true if url is a local file that can be opened with QFile. Otherwise returns false. Local file urls have either a qrc: or file: scheme.

Note: On Android, urls with assets: or content: scheme are also considered local files.

[static] QString QQmlFile::urlToLocalFileOrQrc(const QString &url)

If url is a local file returns a path suitable for passing to QFile. Otherwise returns an empty string.

See also isLocalFile.

[static] QString QQmlFile::urlToLocalFileOrQrc(const QUrl &url)

If url is a local file returns a path suitable for passing to QFile. Otherwise returns an empty string.

See also isLocalFile.

© 2024 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.