[Solved] Compiler report error after adding Q_OBJECT in header file
-
I wrote a class which inherit QWizardPage with UI form(*.ui).
@
#include "QWizardPage.h"namespace Ui {
class PageReport;
}class PageReport : public QWizardPage
{
Q_OBJECT
public:
...... //other impelementation
};
@It works well. But when I want to share the UI form with some other wizard pages. I wrote another class which inherit the class I wrote previously. So that I can reuse the UI form and some common functions in the sub-class.
@
#include "pagereport.h"class PageReportDone : public PageReport
{
Q_OBJECT // it generated some error
public:
...... //other impelementation
};
@Here is the problem, the compiler reported the following error:
@
error: undefined reference to `vtable for PageReportDone'
@If I remove the Q_OBJECT from the header file of PageReportDone, the compiler would work. But I am afraid if there would be some disorder, bugs or some invisible problem afrer removing the Q_OBJECT macro.
How can I reuse the form with all QObject function working correctly? or I can just remove the Q_OBJECT without worrying about the QObject related function does not work.
-
Rerun qmake after adding of remove Q_OBJECT macros and make sure the header is listed in HEADERS
-
Thank you. This problem was solved after rerun qmake. :-)
-
Be sure and edit the initial thread to add [Solved] to the title. Thanks!