完成代码
当你编写代码时,Qt Creator 会建议你使用属性、ID 和代码片段来完成代码。它会针对当前光标下的语句显示建议列表。
选择Tab或Enter以接受所选建议并完成代码。
完成 C++ 代码的建议。
完成 QML 代码的建议。
要随时打开建议列表,请选择Ctrl+Space。如果只有一个选项可用,Qt Creator 会自动插入该选项。
可用类型摘要
下表列出了代码自动补全的可用类型以及每种类型使用的图标。
图标 | 说明 |
---|---|
![]() | 类 |
![]() | 枚举 |
![]() | 枚举器(枚举的值) |
![]() | 函数 |
![]() | 私有函数 |
![]() | 受保护函数 |
![]() | 变量 |
![]() | 一个私有变量 |
![]() | 受保护变量 |
![]() | 一个信号 |
![]() | 一个槽 |
![]() | 一个私人槽 |
![]() | 受保护槽 |
![]() | 一个 C++ 关键字 |
![]() | 一个 C++ 代码片段 |
![]() | 一个 QML 类型 |
![]() | 一个 QML 代码片段 |
![]() | 宏 |
![]() | 命名空间 |
完整代码片段
代码片段可由多个变量组成,您可为这些变量指定值。在列表中选择一个项目,然后选择Tab或Enter来完成代码。选择Tab在变量之间移动并为其指定值。为变量指定值时,代码段中所有变量实例都会重命名。
C++ 代码片段。
QML 代码片段。
另请参阅 完整 CMake 代码、Nim、在自动完成菜单中添加代码片段、完成和片段。
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.