Qt: Signals and slots Error: undefined reference to `vtable for

前端 未结 5 761
走了就别回头了
走了就别回头了 2020-12-03 16:54

Following example from this link: http://developer.kde.org/documentation/books/kde-2.0-development/ch03lev1sec3.html

#include 
#include 

        
5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-03 17:32

    This issue may be caused by some of the following reasons. I have stumbled on all of them from time to time.


    Your class header may be missing the Q_OBJECT macro. Add the macro to the header as already noted by other answers.

    class MyWidg : public QWidget
    {
        Q_OBJECT
    

    Your class header may not be parsed by the moc. Add the header file in the HEADERS definitions of your .pro (or .pri) project file.

    HEADERS += file.h
    

    If none of the above is true, then you probably need to run qmake again to make sure moc parses the header again, just in case the Q_OBJECT macro was added in the header after the qmake was run. Just run qmake again.

提交回复
热议问题