QT compile time undefined reference to 'vtable for HVSView'

107 Views
No Comments

A total of 417 characters, expected to take 2 minutes to complete reading.

Question

QT compile time undefined reference to 'vtable for HVSView'

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!

QT compile time undefined reference to 'vtable for HVSView'

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!

END
 0
Comment(No Comments)
验证码
en_USEnglish
Article Directory