Qt Creator: When I have a file in a subdir of the project, it's not included in project-wide search

时光毁灭记忆、已成空白 提交于 2019-12-11 07:03:57

问题


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.

Is this a bug in Qt Creator and is it something I can fix in the options?

Qt Creator version: 4.1.0.

Further notes

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

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.

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.

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:


  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.

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

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



来源:https://stackoverflow.com/questions/40429513/qt-creator-when-i-have-a-file-in-a-subdir-of-the-project-its-not-included-in

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!