Qt for Android 环境变量

启用或禁用变通方法

Qt for Android 使用一些环境变量来启用/禁用某些变通方法:

常用变量

变量说明
qt_android_noo_exit_call在某些情况下,Android 应用程序在调用exit() 时可能无法安全地清理所有线程,因而可能会崩溃。这是因为有 C++ 线程在运行,如果不加入这些线程而将其销毁,应用程序就会终止。这些线程无法加入,因为无法知道它们是否在运行。此标记可避免调用exit() ,让 Android 系统来处理,但代价是不尝试运行全局析构函数。
qt_android_enable_workaround_to_disable_predictive_text允许隐藏预测文本建议,主要是密码字段。某些设备无法正确处理此功能。更多信息,请参阅 "预测文本"。
qt_android_enable_right_mouse_from_long_press将长触按解释为鼠标右键单击事件。
qt_android_disable_accessibility禁用辅助功能。这将阻止处理辅助功能事件。

不常用变量

变量说明
qt_android_font_location设置系统字体的自定义路径。
qt_android_max_assets_cache_sizeassets 文件夹下资产的缓存大小。
qt_android_disable_glyph_cache_workaround请参阅文本字形缓存
qt_android_raster_image_depth (光栅图像深度)
qt_android_minimum_mouse_double_click_distance_workaround (最小鼠标双击距离)
qt_android_background_actions_queue_size当 Android 应用暂停或处于非活动状态时,它可能会继续接收来自 BroadcastReceiver 或 Service 等组件的 UI 更新。这些更新会排队等待,直到应用程序恢复。队列可能会无限增长,导致应用程序再次激活后处理这些更新时产生额外的内存占用和延迟。该环境变量通过引入队列大小限制来解决这一问题。一旦达到指定的限制,就会丢弃最旧的条目,添加最新的条目,从而防止无限制增长。默认情况下,队列不受约束,也不设置此环境变量。此外,如果将环境变量设置为负数,队列将保持非绑定状态。

例如,QT_ANDROID_BACKGROUND_ACTIONS_QUEUE_SIZE=100 将队列限制为 100 个动作。

注意: 尽管相关,但这些与 Qt For Android 使用的 CMake 命令或变量不同,请参阅Qt for Android CMake 配置

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