hello all,
I am trying to compile this canned example in QT4 , but the compiler spews out an error messagethat I have never seen before.
The *.cpp file:
#include <QtGui>
#include "finddialog.h"
FindDialog::FindDialog(QWidget *parent)
: QDialog(parent)
{
label = new QLabel(tr("Find &what:"));
lineEdit = new QLineEdit;
label->setBuddy(lineEdit);
caseCheckBox = new QCheckBox(tr("Match &case"));
backwardCheckBox = new QCheckBox(tr("Search &backward"));
findButton = new QPushButton(tr("&Find"));
findButton->setDefault(true);
findButton->setEnabled(false);
closeButton = new QPushButton(tr("Close"));
connect(lineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(enableFindButton(const QString &)));
connect(findButton, SIGNAL(clicked()),
this, SLOT(findClicked()));
connect(closeButton, SIGNAL(clicked()),
this, SLOT(close()));
QHBoxLayout *topLeftLayout = new QHBoxLayout;
topLeftLayout->addWidget(label);
topLeftLayout->addWidget(lineEdit);
QVBoxLayout *leftLayout = new QVBoxLayout;
leftLayout->addLayout(topLeftLayout);
leftLayout->addWidget(caseCheckBox);
leftLayout->addWidget(backwardCheckBox);
QVBoxLayout *rightLayout = new QVBoxLayout;
rightLayout->addWidget(findButton);
rightLayout->addWidget(closeButton);
rightLayout->addStretch();
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addLayout(leftLayout);
mainLayout->addLayout(rightLayout);
setLayout(mainLayout);
setWindowTitle(tr("Find"));
setFixedHeight(sizeHint().height());
}
void FindDialog::findClicked()
{
QString text = lineEdit->text();
Qt::CaseSensitivity cs =
caseCheckBox->isChecked() ? Qt::CaseSensitive
: Qt::CaseInsensitive;
if (backwardCheckBox->isChecked()) {
emit findPrevious(text, cs);
} else {
emit findNext(text, cs);
}
}
void FindDialog::enableFindButton(const QString &text)
{
findButton->setEnabled(!text.isEmpty());
}
The header file;
#ifndef FINDDIALOG_H
#define FINDDIALOG_H
#include <QDialog>
class QCheckBox;
class QLabel;
class QLineEdit;
class QPushButton;
class FindDialog : public QDialog
{
Q_OBJECT
public:
FindDialog(QWidget *parent = 0);
signals:
void findNext(const QString &str, Qt::CaseSensitivity cs);
void findPrevious(const QString &str, Qt::CaseSensitivity cs);
private slots:
void findClicked();
void enableFindButton(const QString &text);
private:
QLabel *label;
QLineEdit *lineEdit;
QCheckBox *caseCheckBox;
QCheckBox *backwardCheckBox;
QPushButton *findButton;
QPushButton *closeButton;
};
#endif
The compiler puke:
obj\Debug\finddialog.o:: In function `ZN10FindDialogC2EP7QWidget':
C:\Documents and Settings\jim\My Documents\CB_projects\find\finddialog.cpp:7: undefined reference to `vtable for FindDialog'
C:\Documents and Settings\jim\My Documents\CB_projects\find\finddialog.cpp:7: undefined reference to `vtable for FindDialog'
obj\Debug\finddialog.o:: In function `ZN10FindDialogC1EP7QWidget':
C:\Documents and Settings\jim\My Documents\CB_projects\find\finddialog.cpp:7: undefined reference to `vtable for FindDialog'
C:\Documents and Settings\jim\My Documents\CB_projects\find\finddialog.cpp:7: undefined reference to `vtable for FindDialog'
obj\Debug\finddialog.o:: In function `ZN10FindDialog11findClickedEv':
C:\Documents and Settings\jim\My Documents\CB_projects\find\finddialog.cpp:58: undefined reference to `FindDialog::findPrevious(QString const&, Qt::CaseSensitivity)'
C:\Documents and Settings\jim\My Documents\CB_projects\find\finddialog.cpp:60: undefined reference to `FindDialog::findNext(QString const&, Qt::CaseSensitivity)'
obj\Debug\finddialog.o:: In function `ZSt3minIjERKT_S2_S2_':
)]+0x1c):: undefined reference to `FindDialog::staticMetaObject'
:: === Build finished: 7 errors, 0 warnings ===
What baffles me is the distorted reference to the function
FindDialog::FindDialog(QWidget *parent) : QDialog(parent)
which comes out as `ZN10FindDialogC2EP7QWidget': in the compiler output.
What is this telling me?
Also I understand that vtable refers to the use of virtual functions, but I don't see any virtual declarations anywhere.
Does all this simply mean that it cant find QDialog???