Qt World Summit: Submit your Presentation

Single headers not displayed

  • Hi,

    I have a single header file in my project which I need as an interface definition. The project compiles without errors but the file is not shown in the project view. I also tried to create a new header with QtCreator which works but it is not shown in the tree. The other header where I have a cpp file as well are shown.
    How can I get the creator to display such headers?


  • Does .pro file of your project contain the header name in its HEADERS section?

  • I am using CMake but there it is in the necessary variable otherwise it would not compile.

  • Cmake does not require headers to be listed at all! So your code will compile, even if your headers are missing. Creator will not consider any header not listed to not be part of the project and not list it.

  • However, the header is listed so shouldn't Creator list it then? As I mentioned above I also tried to create a header file out of Creator and there it should know that it is needed.
    It is quite complicated to switch to external editors every time I have to change those headers.

  • I have done exactly the same thing before without any issues. Have you done what Dmitry suggested and checked your .pro file to confirm that your interface file is listed under HEADERS?

  • As I wrote before, I don't have a .pro file, it is cmake.

  • Sorry, cmake syntax is just too complex for creator to fully understand it! You will have to add the files you create from inside creator to cmake manually.

    There is just too little chance of creator putting it into the right place:-(

  • But the thing I am a little bit worried about is, that I tried to add a header file from within Creator. So nothing with cmake or anything just New->C++-Header and it still did not show up in the list. I guess this is the same reason why the header from cmake is not shown.

  • Creator extracts a list of files that belong to a project from the build system directly (.pro-file, CMakeLists.txt, Makefile.am or whatever). It does not keep any extra information around. So if your build system does not consider something as belonging to the project, then creator will not list it as such. That way what you see in creator and what your build system processes are always in sync.

    For other build systems creator does add the files it creates using New->C++-Header, but that can not be done in a reliable way for all the build systems we support, so we do not do it everywhere. So you as a cmake user will need to make sure your headers are listed in CMakeLists.txt. Creator will not add anything there because it will most likely just mess up your build system for you:-)

  • That sounds good so far but anyway, the file in my case is listed and the other headers where I have cpp files as well are shown and all headers are in the same variable. That's why I actually don't understand why this one is not listed.

  • Apologies, I didn't quite understand the CMake angle. My bad.

Log in to reply