"undefined reference" in moc_mainwindow after deleting GUI element
-
Hi everyone,
I'm quite new in QT, but im hanging in there.
Im working on a project, and everything was OK, until i deleted spin boxes (and related functions) from my main window, because a decided to use some other tools instead.
The problem is that now the App just doesn't compile, i have 3 errors referring to this 3 spinboxes on the moc_mainwindow file. No matter how much times i clean the project, delete the files, or even edit manually the moc file, i cant get rid of this.
Last time i had this problem, i created a new project, and copied manually the files and GUI from the old project to the new one. This time i want to fix it the right way, it cant be possible that every time i delete an element from my GUI i have this problem, what should i do next time?
I already googled a lot with no further success, please give me a hand on this, it's very basic, so i hope someone had successfully over passed this situation.
Thanks!
-
Hi,
moc file is a code generated file so it doesn't make any sense to edit it by hand, next time at compilation time will be generated in the same way
deleting widgets from any ui form in designer for sure will be reflected in the ui header file generated ... I think the undefined references come from elsewhere
I don't know how big is your project but try something simple on a small project and figure out if the issue persists?
-
Try running qmake again on the project before rebuilding.
-
When Gui elements are changed in designer and you encounter this error it is usually a QMake rebuild! When it has to do with automatic slot creation a manual delete of the "switch/case" value might be needed!
Greetz -
I had problem in mainwindow.h . The slot functions were declared there, which after removing solved the problem.
-
@RahulM44 And you really think this is important on a topic which is more than 7 years old?
-
Maybe OP is still looking for a solution 😂 You never know 😉
-
Hello, I know this is a very old topic but if this helps anyone.
This error occurs because the moc file is auto-generated, so if you don't remove all the declarations from the slots, it doesn't matter how many times you remove them from the moc file. you have to look for the names of the deleted objects in the headers or cpp files of your project, delete them and compile again.