I'm following Qt's guide for using a QPushButton
.
I did exactly as the guide suggests, but I'm getting a compilation error:
./src/mainwindow.o: In function `MainWindow::MainWindow(QWidget*)':
mainwindow.cpp:(.text+0x1d): undefined reference to `vtable for MainWindow'
./src/mainwindow.o:mainwindow.cpp:(.text+0x25): more undefined references to `vtable for MainWindow' follow
collect2: error: ld returned 1 exit status
make: *** [HelloWorldProj] Error 1
I tried adding a destructor:
~MainWindow(){};
but the problem persisted.
I have no virtual functions declared, except one function inside QMainWindow
(the class I'm inheriting from):
virtual QMenu *createPopupMenu();
Should this be defined in my class?
You need to set CMAKE_AUTOMOC
to ON
in our CMake file.
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
"The AUTOMOC target property controls whether cmake inspects the C++ files in the target to determine if they require moc to be run, and to create rules to execute moc at the appropriate time." - Reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With