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.