A total of 417 characters, expected to take 2 minutes to complete reading.
Question
undefined reference to `vtable for < 你的类名 >`
Reason
You created a new file to inherit. QObject similar QT class, but QT does not create for you moc file. Causes the moc file not to be included or created in the linker parameters.
Solution
Qt Creator
Find the following in the menu:
Build → Run qmake
Build → Rebuild All
Then the project will be refactored.
Or:
项目右键 ->Add Existing Files
Add project files manually.
CLion or CMake Project
Find and modify CMakeLists.txt, to ensure add_executable
The project name in the method follows all .h,.cpp and .ui File!
In the above picture, I adopted file
Method to get all the files in the directory. Suppose I add here test.cpp and test.h The new class, and does not use the method of traversing directories, then I change here:
add_executable(3DSystemHelper test.cpp test.h)
Can be compiled through! Must include test.h File!