Obsolete Members for Qt

QtQml 类型的以下成员已被废弃。提供这些成员是为了确保旧的源代码能够继续运行。我们强烈建议不要在新代码中使用它们。

方法

  • string atob(string data) (deprecated in 6.11)
  • string btoa(string data) (deprecated in 6.11)
  • var include(string url, jsobject callback) (deprecated)

方法文档

[deprecated in 6.11] string atob(string data)

自 QtQml 6.11 起,此方法已弃用。我们强烈建议不要在新代码中使用它。

该方法在解码字符串之前会将其转换为 Latin-1 格式,然后将结果解释为 UTF-8。

ASCII 转二进制 — 此函数对 base64 编码的data 字符串进行解码并返回该字符串。


[deprecated in 6.11] string btoa(string data)

自 QtQml 6.11 起,此方法已被废弃。我们强烈建议在新代码中不要使用它。

该方法在对字符串进行编码之前,会先将其转换为 UTF-8 格式。

二进制转ASCII — 此函数返回data 的Base64编码。


[deprecated] var include(string url, jsobject callback)

此方法已弃用。我们强烈建议不要在新代码中使用它。

不应使用此方法。请改用 ECMAScript 模块,以及原生的 JavaScript 语句 `import ` 和 `export `。

包含另一个 JavaScript 文件。此方法仅可在 JavaScript 文件内部使用,而不能在常规的 QML 文件中使用。

此方法将url 中的所有函数导入到当前脚本的命名空间中。

Qt.include() 返回一个描述操作状态的对象。该对象有一个属性status ,其值设置为以下之一:

符号值描述
result.OK0包含操作已成功完成。
result.LOADING1正在从网络加载数据。
result.NETWORK_ERROR2在获取 URL 时发生网络错误。
result.EXCEPTION3在执行包含的代码时发生了 JavaScript 异常。在此情况下,将设置一个额外的exception 属性。

随着操作的进行,status 属性将不断更新。

如果提供了回调函数,则在操作完成时会调用callback 。该回调函数接收的对象与 Qt.include() 调用返回的对象相同。

警告: 在严格模式下使用 此函数,并不会将标识符实际放入当前上下文中。


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