PDA

View Full Version : Error in MOC file



Computer Hater
28th June 2011, 22:33
Hi,
I have the following problem using Qt Creator:

In my menu I added an option for testing actions associated with it. I removed the option again (I think I first removed the action from the Action Editor, then the menu option itself).
Ever since then I've been getting a compiler error that is actually referring to the file "moc_mainwindow.cpp", so it's in an auto-generated file (see "moc file error.jpg").
I also removed some other actions from the Action Editor, but I only get an error for this one.

AFAIK I have removed every remnant of that option from all visible elements in the design area (see "mainmenu design.jpg"), so I would expect them to be removed behind the scenes, i.e. in auto-generated files, as well. Yet the compiler seems to still find it somewhere and include it when generating dependent files. Apparently I have to remove it manually before the program will compile. But where ?

Thanks in advance.

mvuori
28th June 2011, 22:48
I have no idea what is going on, but I have found that even if you ask Qt Creator to rebuild it may not remove all traces of the previous state. So, I'd suggest that you remove by hand all .moc (ant other temporary build giles) files before a rebuild.

Another this is, you should stop being a "Computer Hater" because as long as you are, your brain doens't work that well with computer related stuff, including software development...

Computer Hater
28th June 2011, 23:15
Thanks for the response.
I actually did something similar before. I restarted the project and manually copied all non-automatic files over from the old project, which didn't help.
But I've found the problem now. I forgot to manually remove the declaration of the problematic action from the mainwindow.h header file. Don't know why I missed that.

You're right about the name. It was a bad choice of user name. But what's done is done. :-/
It's hard not to get upset sometimes when things constantly go wrong, for apparently arbitrary reasons, and also not just with software development or computers. Anyway...

schnitzel
29th June 2011, 17:53
have you tried doing a project clean?

sometimes Qt Creator can get a bit confused when the designer generated code gets out of sync, I usually do this:
close Qt Creator
delete debug/release folder
delete Makefile.* (there should be three)
delete object_script.<proj name>.* (there are two of these)
delete <proj name>.pro.user

reopen the project and rebuild

make a habit of archiving your project before tinkering with things in the designer.

I just realized that you actually solved your problem - oh well, the above steps are still useful for doing a project clean manually.

Computer Hater
29th June 2011, 20:18
Thank you for the hints anyway, schnitzel. I saved them for later problems. ;-)
Also, I feel hungry now. Strange...