QQmlFile Class
QQmlFile 类提供了用于对 URL 进行分类的静态辅助方法。更多内容...
| 头文件: | #include <QQmlFile> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Qml) target_link_libraries(mytarget PRIVATE Qt6::Qml) |
| qmake: | QT += qml |
静态公共成员
| bool | isLocalFile(const QString &url) |
| bool | isLocalFile(const QUrl &url) |
| QString | urlToLocalFileOrQrc(const QString &url) |
| QString | urlToLocalFileOrQrc(const QUrl &url) |
详细说明
QQmlFile 提供了一些静态实用方法,用于按照QQmlEngine 在从中加载内容时所采用的方式对 URL 和文件名进行分类。
成员函数文档
[static] bool QQmlFile::isLocalFile(const QString &url)
如果url 是一个可通过QFile 打开的本地文件,则返回true ;否则返回false 。本地文件的 URL 采用qrc: 或file: 方案。
注意:在 Android系统上 ,以assets: 或content: 开头的 URL 也被视为本地文件。
[static] bool QQmlFile::isLocalFile(const QUrl &url)
如果url 是一个可通过QFile 打开的本地文件,则返回true ;否则返回false 。本地文件的 URL 采用qrc: 或file: 方案。
注意:在 Android系统上 ,以assets: 或content: 开头的 URL 也被视为本地文件。
[static] QString QQmlFile::urlToLocalFileOrQrc(const QString &url)
如果url 是本地文件,则返回一个适合传递给QFile 的路径。否则返回一个空字符串。
另请参阅 isLocalFile 。
[static] QString QQmlFile::urlToLocalFileOrQrc(const QUrl &url)
如果url 是本地文件,则返回一个适合传递给QFile 的路径。否则返回一个空字符串。
另请参阅 isLocalFile 。
© 2026 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.