1.编译提示下面错误
说明:FindDialog是我写的QDialog的子类,findPrevious是FindDialog的signal
finddialog.cpp:(.text+0x567): undefined reference to `FindDialog::findPrevious(QString const&, Qt::CaseSensitivity)'
finddialog.cpp:(.text+0x591): undefined reference to `FindDialog::findNext(QString const&, Qt::CaseSensitivity)'
原因:在FindDialog的definition中没有Q_OBJECT
解决办法加入Q_OBJECT即可解决
2.编译提示下面错误
finddialog.o: In function `FindDialog::FindDialog(QWidget*)':
finddialog.cpp:(.text+0x27): undefined reference to `vtable for FindDialog'
finddialog.cpp:(.text+0x2f): undefined reference to `vtable for FindDialog'
finddialog.cpp:(.text+0x3b): undefined reference to `FindDialog::staticMetaObject'
finddialog.cpp:(.text+0xb5): undefined reference to `FindDialog::staticMetaObject'
finddialog.cpp:(.text+0xfe): undefined reference to `FindDialog::staticMetaObject'
finddialog.cpp:(.text+0x147): undefined reference to `FindDialog::staticMetaObject'
finddialog.cpp:(.text+0x190): undefined reference to `FindDialog::staticMetaObject'
finddialog.o:finddialog.cpp:(.text+0x36f): more undefined references to `FindDialog::staticMetaObject' follow
finddialog.o: In function `FindDialog::findClicked()':
finddialog.cpp:(.text+0x567): undefined reference to `FindDialog::findPrevious(QString const&, Qt::CaseSensitivity)'
finddialog.cpp:(.text+0x591): undefined reference to `FindDialog::findNext(QString const&, Qt::CaseSensitivity)'
原因:工程文件没有更新
解决办法:重新进行编译
qmake -project
qmake 工程名.pro
make