更改文本编码
要在Edit 模式下在编辑器工具栏 (4) 上显示当前文件的文件编码,请转到首选项>Text Editor >Display >Display file encoding 。
要更改文本编码,请在工具栏上选择该编码,然后在Text Encoding 对话框中选择新编码:
要使用所选编码重新加载文件,请选择Reload with Encoding 。
要使用新编码保存文件,请访问Save with Encoding 。
设置默认编码
要定义默认文件编码,请选择首选项>Text Editor >Behavior ,然后在Default encoding 中选择合适的选项。
Qt 需要 UTF-8 编码的源文件,因此默认编码设置为UTF-8 。
如果尝试编辑非 UTF-8 编码的文件,会看到以下错误信息:Error: Could not decode "filename" with "UTF-8"-encoding. Editing not possible.
要解决这个问题,请使用文件转换工具将文件编码转换为 UTF-8。否则,将字符串常量转换为QString 可能无法达到预期效果。
如果不开发 Qt 应用程序,可以将其他编码选项设为默认编码。选择System 选项可使用系统使用的文件编码。
Copyright © The Qt Company Ltd. and other contributors. 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.