Qt Creator: When I have a file in a subdir of the project, it's not included in project-wide search
Let's say my project is called
foo. I created a subdir called
fooroot, using Windows Explorer. I put my
subdir. Then I tried to do a project-wide search for "text" in my project. To do this, I pressed
Scope, wrote "text" in
Search for. No matches were found, though
main.qmldoes contain the string "text". When
main.qmlis 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.
Is the file listed in a .pro file or any of its includes?
The files listed .pro file, any its includes and also the files loaded with the subdir are shown in the project pane in creator. Therefore all those files are searched for a project wide search. Another requirement is that the project focus should be on the main .pro file.
@koahnig 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.
Since I am not using qml I am not sure what requirements there are.
I am working with C++ where you distinguish between source (.cpp) and header (.h included in *.cpp) files. The compiler requires basically only the *.cpp files for compiling. The header files are found through INCLUDEPATH or also other means settings.
Being lazy you could think of just added *.cpp files to your .pro. However, this is a really bad idea, because Qt creator cannot detect that those have changed respectively there might be no dependency on includes in your make.
Sometimes you simply forget an include to add to .pro and I have noticed that those includes are searched.
That it is working for you now, may have something to do with a rerun of qmake. Just wait and see, if teh problem comes back. Eventually for some reason qmake was not triggered.
Note: Since I am not working with qml at all, I am not sure, if you are actually using qmake. Checkout if you actually have "Run qmake" under "Buld" available.