Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Another noob question - Can't see ui_foo.h at compile



  • Another noob question.
    My most humble apologies - I swear I'll get it worked out eventually.

    So, I'm running Qt Creator 4.9.0 based on Qt 5.12.2 on Windows 10.

    I'm following Blanchette and Summerfield.

    So, I've created a blank project and used the designer to create a GUI form.
    I've run qmake to create ui_foo.h in the build folder.
    When I go to compile, it gives a pile of errors as if it cannot see the ui_foo.h.

    I even took a copy of ui_foo.h and placed it with all my other files and then explicitly did a #include of the file in the foo.cpp file where its contents are called - it made no difference.
    I added it to the project explicitly and ensured that it was included the "HEADERS" in the foo.pro file - No joy.
    I did something similar last time and, after mucking around, it worked (even though I was told that I don't need to - Qt should find the ui_foo.h in the Build folder by itself.

    I've deleted the ui_foo.h and re-run qmake, then re-run compile - No joy.

    I even deleted all my explicit #include of it and the local copy of ui_foo.h from my project file (as I'm told will still work!)

    Is there something I'm missing?
    Is it something to do with the fact that I created this project from an empty project and have not set something/included something/set an option/etc?

    Many thanks.

    Uberlinc.


  • Lifetime Qt Champion

    @uberlinc said in Another noob question - Can't see ui_foo.h at compile:

    I even took a copy of ui_foo.h and placed it with all my other files

    Dont! do! that!

    Problems like yours often appear, because you have a mixture of generated files (Makefiles, ui_xxx.h and object files) in your source and your build folder.

    The best tip I can give you: stick to shadow-builds. Use the source folder only for sources, let the build system place all generated files in the separate build folder.

    even though I was told that I don't need to - Qt should find the ui_foo.h in the Build folder by itself.

    It does, because millions of programmers use that mechanism day by day.

    Is there something I'm missing?

    I'd start by closing Creator, deleting the build folder(s), the .pro.user file and then clean up the source directory so it really only contains .pro, .cpp, .h, and .ui files.

    If that still don't work, please upload a copy of your project so we can try and analyze it.

    Regards



  • Thanks for your help.
    It turned out to be just plain-old sloppy coding that came from a few places that looked like it was one culprit.
    I found 'em and fixed 'em.

    Sorry for wasting your time.

    Uberlinc.


Log in to reply