QQmlFile Class
QQmlFile 类提供了对 URL 进行分类的静态实用程序方法。更多
Header: | #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 提供了一些静态实用程序方法,用于对 URL 和文件名进行分类,就像QQmlEngine 从 URL 和文件名加载内容时那样。
成员函数文档
[static]
bool QQmlFile::isLocalFile(const QString &url)
如果url 是可通过QFile 打开的本地文件,则返回true
。否则返回false
。本地文件 URL 采用qrc:
或file:
方案。
注: 在 Android 系统中,使用assets:
或content:
方案的 urls 也被视为本地文件。
[static]
bool QQmlFile::isLocalFile(const QUrl &url)
如果url 是可通过QFile 打开的本地文件,则返回true
。否则返回false
。本地文件 URL 采用qrc:
或file:
方案。
注: 在 Android 系统中,使用assets:
或content:
方案的 urls 也被视为本地文件。
[static]
QString QQmlFile::urlToLocalFileOrQrc(const QString &url)
如果url 是本地文件,则返回适合传递给QFile 的路径。否则返回空字符串。
另请参见 isLocalFile 。
[static]
QString QQmlFile::urlToLocalFileOrQrc(const QUrl &url)
如果url 是本地文件,则返回适合传递给QFile 的路径。否则返回空字符串。
另请参见 isLocalFile 。
© 2025 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.