在项目或文件系统中搜索
要在“Search Results ”视图中搜索项目或文件系统:
- 按Ctrl+Shift+F
- 转到“Edit ” > “Find/Replace ” > “Advanced Find ”,然后选择“Open Advanced Find ”。
- 转到“Search Results ”视图。
搜索范围和搜索条件决定了“Qt Creator ”在何处查找搜索字符串、如何将字符串与文本进行匹配,以及显示哪些结果。
在单个项目中搜索
- 在“Scope ”中,选择“Single Project ”。

- 在Search for 中,输入要查找的字符串。
- 选择相关选项,以设置搜索是否区分大小写、仅搜索完整单词、使用正则表达式,或忽略二进制文件和生成的文件。
- 在“Project ”中,选择要搜索的打开项目。选择“Current ”可在当前活动文件所属的项目中进行搜索。
- 在“File pattern ”中,指定文件模式以将搜索范围限制为匹配该模式的文件。例如,若要仅在“
.cpp”和“.h”文件中搜索某个字符串,请输入*.cpp,*.h。 - 在“Exclusion pattern ”中,指定文件模式以将某些文件从搜索中排除。
- 选择“Search ”。
如果找不到某些文件,请参阅“指定项目内容”以了解如何将它们声明为项目的一部分。
在所有项目中搜索
- 在“Scope ”中,选择“All Projects ”。

- 设置搜索条件。
- 选择“Search ”。
在文件系统中搜索
除了可用于搜索所有项目的选项外,您还可以选择要使用的搜索引擎和要搜索的目录。
- 在“Scope ”中,选择“Files in File System ”。

- 在“Search for ”中,输入要查找的字符串。
- 在“Search engine ”中,选择要使用的搜索引擎:
- 选择“Internal ”以使用Qt Creator 搜索引擎。
- 选择“Git Grep ”以使用 Git,仅搜索 Git 工作树中的受监控文件。若要将搜索范围限制在 HEAD、某个标签、本地或远程分支,或某个提交哈希上,请输入引用。若要搜索整个文件系统,请将该字段留空。
- 选择“Silver Searcher ”以使用实验性的 Silver Searcher 插件。
- 在“Directory ”中,选择要搜索的目录。选择“Browse ”以定位该目录,或选择“Current ”以在当前活动文件所在的目录中进行搜索。
- 选择“Search ”。
搜索和替换
要替换现有文本的所有出现位置:
- 选择“Search & Replace ”。

- 在“Replace with ”中输入新文本。
- 选择“Replace ”。
若要在替换时保留原始文本的大小写,请选择Preserve case 。此处同样适用“替换时保留大小写”中列出的规则。
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.