Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt Creator: When I have a file in a subdir of the project, it's not included in project-wide search
Forum Update on Monday, May 27th 2025

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

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
qt creatorqt creator 4.1search
4 Posts 2 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Stefan Monov76S Offline
    Stefan Monov76S Offline
    Stefan Monov76
    wrote on last edited by
    #1

    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.

    K 1 Reply Last reply
    0
    • Stefan Monov76S Stefan Monov76

      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.

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @Stefan-Monov76

      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.

      Vote the answer(s) that helped you to solve your issue(s)

      Stefan Monov76S 1 Reply Last reply
      2
      • K koahnig

        @Stefan-Monov76

        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.

        Stefan Monov76S Offline
        Stefan Monov76S Offline
        Stefan Monov76
        wrote on last edited by
        #3

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

        K 1 Reply Last reply
        0
        • Stefan Monov76S Stefan Monov76

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

          K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          @Stefan-Monov76

          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.

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved