您的位置:首页 > 编程语言 > C语言/C++

学习C++ GUI Programming with Qt 4遇到的问题(1)

2014-03-02 17:27 627 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: