Out-of-line definition of --constructor-- does not match any declaration in --class--
Unsolved
General and Desktop
-
I have this header file (
graphics_view_zoom.h
):#include <QObject> #include <view.h> class Graphics_view_zoom : public QObject { Q_OBJECT public: Graphics_view_zoom(View* view); // stuff private: View* _view; // other stuff };
And this cpp file (
graphics_view_zoom.cpp
):#include "Graphics_view_zoom.h" #include <view.h> Graphics_view_zoom::Graphics_view_zoom(View* view) // error: out-of-line definition of 'Graphics_view_zoom' does not match any declaration in 'Graphics_view_zoom' : QObject(view), _view(view) { // more stuff }
Why does this happen? It works fine when I use
QGraphicsView*
instead ofView*
(my custom classView
inherits fromQGraphicsView
). Any help is appreciated! -
Hi,
In your declaration you pass an instance and in the implementation you pass a pointer.
-
I have this header file (
graphics_view_zoom.h
):#include <QObject> #include <view.h> class Graphics_view_zoom : public QObject { Q_OBJECT public: Graphics_view_zoom(View* view); // stuff private: View* _view; // other stuff };
And this cpp file (
graphics_view_zoom.cpp
):#include "Graphics_view_zoom.h" #include <view.h> Graphics_view_zoom::Graphics_view_zoom(View* view) // error: out-of-line definition of 'Graphics_view_zoom' does not match any declaration in 'Graphics_view_zoom' : QObject(view), _view(view) { // more stuff }
Why does this happen? It works fine when I use
QGraphicsView*
instead ofView*
(my custom classView
inherits fromQGraphicsView
). Any help is appreciated!Is your custom
View
class aQObject
? Otherwise your call of theQObject()
c'tor withview
as argument won't work.