Undefined reference to resizeEvent(QResizeEvent*)
-
My application includes a class “Parabola” which is a subclass of QOpenGLWindow, which is a subclass of QObject. The Parabola class includes the Q_OBJECT macro:
#ifndef PARABOLAWINDOW_H #define PARABOLAWINDOW_H #include <QOpenGLWindow> #include <QOpenGLFunctions> #include <QOpenGLBuffer> #include <QOpenGLVertexArrayObject> #include <QMatrix4x4> class QOpenGLShaderProgram; class ParabolaWindow : public QOpenGLWindow, protected QOpenGLFunctions { Q_OBJECT
The project compiles, but the linker gives this result:
g++ -Wl,-O1 -Wl,-rpath,/home/oreilly/Qt/5.14.2/gcc_64/lib -o parabola main.o ParabolaWindow.o qrc_qml.o moc_ParabolaWindow.o /home/oreilly/Qt/5.14.2/gcc_64/lib/libQt5Quick.so /home/oreilly/Qt/5.14.2/gcc_64/lib/libQt5Gui.so /home/oreilly/Qt/5.14.2/gcc_64/lib/libQt5QmlModels.so /home/oreilly/Qt/5.14.2/gcc_64/lib/libQt5Qml.so /home/oreilly/Qt/5.14.2/gcc_64/lib/libQt5Network.so /home/oreilly/Qt/5.14.2/gcc_64/lib/libQt5Core.so -lGL -lpthread moc_ParabolaWindow.o:(.data.rel.ro._ZTV14ParabolaWindow[_ZTV14ParabolaWindow]+0xa0): undefined reference to `ParabolaWindow::resizeEvent(QResizeEvent*)' collect2: error: ld returned 1 exit status Makefile:282: recipe for target 'parabola' failed make: *** [parabola] Error 1
Parent class QOpenGLWindow defines method resizeEvent(QResizeEvent*), which is defined in libQt5Gui.so, and I am linking with that library. I have other projects that subclass QOpenGLWindow, yet they do not have this error when I link. What is causing this error?
Thanks!
-
@Tom-asso said in Undefined reference to resizeEvent(QResizeEvent*):
resizeEvent
You defined resizeEvent() in your class but did not implement it.
-
Hi,
Beside @Christian-Ehrlicher good point, you seem to have made it a slot which is wrong. This method will automatically be called but it is not a slot.