Qt Creator:当我在项目的子目录中有一个文件时,它不包含在项目范围的搜索中 [英] Qt Creator: When I have a file in a subdir of the project, it's not included in project-wide search

查看:30
本文介绍了Qt Creator:当我在项目的子目录中有一个文件时,它不包含在项目范围的搜索中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我的项目名为 foo.我使用 Windows 资源管理器在 foo 根目录中创建了一个名为 subdir 的子目录.我把我的 main.qml 文件放在 subdir 中.然后我尝试在我的项目中对文本"进行项目范围的搜索.为此,我按了 Ctrl+Shift+F,在 Scope 中选择了 Project "foo",在 Search 中写入了text"对于.虽然 main.qml 确实包含字符串text",但未找到匹配项.当main.qml在项目根目录下时,发现字符串就好了.

Let's say my project is called foo. I created a subdir called subdir in the foo root, using Windows Explorer. I put my main.qml file in subdir. Then I tried to do a project-wide search for "text" in my project. To do this, I pressed Ctrl+Shift+F, selected Project "foo" in Scope, wrote "text" in Search for. No matches were found, though main.qml does contain the string "text". When main.qml is in the project root, the string is found just fine.

这是 Qt Creator 中的错误吗?我可以在选项中修复它吗?

Qt Creator 版本:4.1.0.

.pro 文件不包含 main.qml,但 .pro 文件包含 RESOURCES += qml.qrc,而 qml.qrc 包含 subdir/main.qml.Creator 中的项目查看器确实在树中显示 main.qml,嵌套为Resources -> qml.qrc ->/-> subdir ->main.qml".

The .pro file doesn't include main.qml, but the .pro file contains RESOURCES += qml.qrc, and qml.qrc contains <file>subdir/main.qml</file>. The project viewer in Creator does show main.qml in the tree, nested as "Resources -> qml.qrc -> / -> subdir ->main.qml".

如果项目焦点"意味着它必须是通过右键单击项目并选择将'myproj'设置为活动项目"设置的活动项目",那么我满足了该要求.

If by "project focus" mean it has to be the "Active project" as set by rightclicking a project and selecting "Set 'myproj' as active project", then I have that requirement fulfilled.

我尝试在项目中包含驻留在项目根目录中的资源文件(称为main2.qml"),以便我可以查看它是否自动包含在 .pro 中.它确实被包括在内,就像这样:

I tried including in the project a resource file (called "main2.qml") that resides in the project root, just so I can see if it gets included in the .pro automatically. It did get included, like this:

DISTFILES += \
    main2.qml

而且,奇怪的是,现在我包含了这个新文件,位于子目录中的旧文件也可以搜索.

And, weirdly, now that I included this new file, the old file that resides in a subdir is also searchable.

即使我从项目中删除了 main2.qml,子目录中的文件仍然可以搜索!它们甚至在我的另一个项目中变得可搜索,而我没有做任何改变!

Even when I removed main2.qml from the project, the files in subdirs remained searchable! They even became searchable in my other project, where I've changed nothing!

很奇怪.我预计搜索很快就会再次出现问题,因此我仍然希望了解可能导致问题的原因.

Very weird. I expect soon search will start having the problem again, so I'd still like tips on what might have caused the problem.

推荐答案

  1. 确保 qml 文件是项目的一部分.

  1. Make sure the qml file is a part of the project.

项目范围搜索仅查找作为项目一部分的文件.它们在磁盘上的位置根本不相关.如果它们没有出现在项目树中,则它们不在项目中.

A project-scope search only looks in files that are a part of your project. Their on-disk location is not relevant at all. If they don't show up in the project tree, they are not in the probject, period.

确保搜索的文件模式包含 qml 文件.

Make sure that the File Pattern for the search includes the qml files.

文件模式元素以逗号分隔(例如 *.c*、*.h、*.qml).使用其他分隔符是一个常见的错误.

The file pattern elements are comma-delimited (e.g. *.c*, *.h, *.qml). It is a common error to use other delimiters.

这篇关于Qt Creator:当我在项目的子目录中有一个文件时,它不包含在项目范围的搜索中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆