Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Out-of-line definition of --constructor-- does not match any declaration in --class--
QtWS25 Last Chance

Out-of-line definition of --constructor-- does not match any declaration in --class--

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 5.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Forfunckle
    wrote on last edited by Forfunckle
    #1

    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 of View* (my custom class View inherits from QGraphicsView). Any help is appreciated!

    Pl45m4P 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      In your declaration you pass an instance and in the implementation you pass a pointer.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • F Forfunckle

        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 of View* (my custom class View inherits from QGraphicsView). Any help is appreciated!

        Pl45m4P Online
        Pl45m4P Online
        Pl45m4
        wrote on last edited by Pl45m4
        #3

        @Forfunckle

        Is your custom View class a QObject? Otherwise your call of the QObject() c'tor with view as argument won't work.


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved