[SOLVED]QObject subclass compile error



  • Hi all,
    I cannot see the problem within this class:

    @

    class TableViewHandler : public QObject
    {
    Q_OBJECT
    public:
    TableViewHandler( QObject* parent = 0 );
    ...
    }

    // implementation
    TableViewHandler::TableViewHandler( QObject* parent) : QObject(parent) {
    // do stuff
    }
    @

    which I cannot compile getting the error:

    @tableviewhandler.o: In function TableViewHandler': /sviluppo/c/WHR-build-desktop/../WHR/tableviewhandler.cpp:5: undefined reference tovtable for TableViewHandler'
    /sviluppo/c/WHR-build-desktop/../WHR/tableviewhandler.cpp:5: undefined reference to vtable for TableViewHandler' tableviewhandler.o: In function~TableViewHandler':
    /sviluppo/c/WHR-build-desktop/../WHR/tableviewhandler.cpp:31: undefined reference to vtable for TableViewHandler' /sviluppo/c/WHR-build-desktop/../WHR/tableviewhandler.cpp:31: undefined reference tovtable for TableViewHandler'
    /sviluppo/c/WHR-build-desktop/../WHR/tableviewhandler.cpp:31: undefined reference to vtable for TableViewHandler' collect2: ld returned 1 exit status make: Leaving directory/sviluppo/c/WHR-build-desktop'
    make: *** [WHR] Error 1
    The process "/usr/bin/make" exited with code 2.
    Error while building project WHR (target: Desktop)
    When executing build step 'Make'@

    no matter what my constructor does. Any suggestion?



  • Clean the project and re-run qmake.

    That should do the trick.



  • I did a clean all and build again, but it did not solved the problem.



  • ...and ran qmake? I usually get those errors when the generated moc files no longer matches the class as it is now. I would also recommend manually deleting all generated files.

    A clean alone does not remove the generated files, nor does it cause qmake to run.





  • Correct, the right sequence is clean all, run qmake, build all.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.