Results 1 to 5 of 5

Thread: Error in MOC file

  1. #1
    Join Date
    Nov 2010
    Posts
    63
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Error in MOC file

    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.
    Attached Images Attached Images

  2. #2
    Join Date
    May 2011
    Posts
    239
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: Error in MOC file

    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...

  3. #3
    Join Date
    Nov 2010
    Posts
    63
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Error in MOC file

    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...

  4. #4
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Error in MOC file

    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.
    Last edited by schnitzel; 29th June 2011 at 17:57. Reason: updated contents

  5. #5
    Join Date
    Nov 2010
    Posts
    63
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Error in MOC file

    Thank you for the hints anyway, schnitzel. I saved them for later problems. ;-)
    Also, I feel hungry now. Strange...

Similar Threads

  1. qstring.h no such file or directory error!
    By wenn32 in forum Newbie
    Replies: 14
    Last Post: 5th May 2011, 15:59
  2. Replies: 4
    Last Post: 13th April 2011, 07:03
  3. Replies: 3
    Last Post: 1st November 2010, 16:33
  4. Replies: 4
    Last Post: 9th May 2010, 16:18
  5. Error in qrc file
    By phillip_Qt in forum Qt Programming
    Replies: 2
    Last Post: 11th March 2008, 06:54

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.