我用QT Designer 生成了的.ui文件,然后用一个类继承了QDialog 和 makefile 生成的 .ui 对应的C++ 文件,编译总是提示"undefined reference to `vtable for" 这个错误! 贴上代码,求帮忙看下,谢谢!
- C/C++ code
#ifndef GOCELL_H#define GOCELL_H#include <QDialog>#include "ui_gocell.h"class GoCell : public QDialog, public Ui::ToCellDialog{ Q_OBJECT public: GoCell(QWidget *parent = 0); private slots: void on_lineEdit_textChanged();};#endif
- C/C++ code
#include <QApplication>#include "gocell.h"GoCell :: GoCell(QWidget *parent) : QDialog(parent){ setupUi(this); QRegExp regExp("[A-Za-z][0-9]{0, 2}"); lineEdit->setValidator(new QRegExpValidator(regExp, this)); connect(okButton, SIGNAL(clicked()), this, SLOT(accept())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));}void GoCell::on_lineEdit_textChanged(){ okButton->setEnabled(lineEdit->hasAcceptableInput());}
- C/C++ code
#include <QApplication>#include "gocell.h"int main(int argc, char* argv[]){ QApplication app(argc, argv); GoCell *dialog = new GoCell; dialog->show(); return app.exec();}
编译提示:“undefined reference to `vtable for GoCell'”
ps:ui_gocell.h 这个头文件是用makefile生成的。求帮忙解决,谢谢了
------解决方案--------------------
重新rcc uic moc,全部编译呢?
------解决方案--------------------
楼主可以看看http://blog.csdn.net/chenlong12580/article/details/7431104