PDA

View Full Version : Qt creator C++ error: No documents matching "ui_mainwindow.h" could be found



zinc zinc
21st September 2021, 23:13
I'm currently using Qt Creator 4.15.2. I tried with creating a new project in the creator, the .h, .cpp, and .ui files are perfectly linked. If I changed anything in the creator, everything is synchronized. When I selected action->Go to slot, it immediately finds everything.

Then I copied the mainwindow.cpp, mainwindow.h and mainwindow.ui files to my own C++ project. My project has lots of other dependencies so it's hard to create this project directly in the creator. I have successfully included QT5 in my project, so, if I don't use the creator but adding everything manually, everything works fine.

I added the ui file to my cmake list, then opened the ui file in Qt creator. When I changed anything in the creator, the ui file is synchronized and the ui_mainwindow.h file is generated. The problem then comes, if I click action->Go to slot, this error pops up:

No documents matching "ui_mainwindow.h" could be found. Rebuilding the project might help.

I have tried every method online but none of them worked. Now if I want to include the actions, I have to manually add them in the ui_mainwindow.h file (in this way, it wouldn't automatically add the actions) or mainwindow.h file, which is tedious. Does anyone have an idea of how this could be solved?

Thank you very much!

d_stranz
22nd September 2021, 02:25
I have to manually add them in the ui_mainwindow.h file

Never manually edit the auto-generated files, like ui_*.h, moc_*.cpp, etc. Any changes you make will be wiped out next time the UIC or MOC tools execute on your .ui file.

Sounds to me like your qmake ,pro file is out of sync with your project. Make sure that everything that was in the ,pro file from the first project is present in the .pro file for the second, non-working project. Manually re-run qmake on this .pro file.