title: Why do I constantly get "unresolved externals" error in Qt creator?
body: <p>I'm making a little GUI program using <strong>Qt creator</strong>, but I get stuck with two "<strong>unresolved externals</strong>" errors. Here are all of my code:
  (By the way, I following the book <strong><em>C++ GUI Programming with Qt4</em></strong>, <em>second edition</em>. This are covered in chapter 2) </p>
  
  <p>I got five files in total:
  (The code are kinda long, so you can skip some and go directly to the end for my explanation.)</p>
  
  <p>First, <strong><em>mainwindow.h</em></strong>:</p>
  
  <pre><code>#ifndef MAINWINDOW_H
  #define MAINWINDOW_H
  
  #include &lt;QMainWindow&gt;
  
  namespace Ui {
  class MainWindow;
  }
  
  class MainWindow : public QMainWindow
  {
      Q_OBJECT
  
  public:
      explicit MainWindow(QWidget *parent = 0);
      ~MainWindow();
  
  private:
      Ui::MainWindow *ui;
  };
  
  #endif // MAINWINDOW_H
  </code></pre>
  
  <p><strong><em>finddialog.h</em></strong>:</p>
  
  <pre><code>#ifndef FINDDIALOG_H
  #define FINDDIALOG_H
  
  #include&lt;QDialog&gt;       
  
  class QCheckBox;
  class QLabel;
  class QLineEdit;
  class QPushButton;
  
  class FindDialog:public QDialog
  {
      Q_OBJECT       
  public:
      FindDialog(QWidget* parent=0);
  
  signals:
      void findNext(const QString &amp;str,Qt::CaseSensitivity cs);
      void findPrevious(const QString &amp;str,Qt::CaseSensitivity cs);
  
  private slots:
      void findClicked();
      void enableFindbuton(const QString&amp; text);
  
  private:
      QLabel* label;
      QLineEdit* lineEdit;
      QCheckBox* caseCheckBox;
      QCheckBox* backwardCheckBox;
      QPushButton* findButton;
      QPushButton* closeButton;
  
  };
  #endif
  </code></pre>
  
  <p><strong>finddialog.cpp:</strong></p>
  
  <pre><code>#include&lt;QtGui&gt;       
  
  #include"finddialog.h"
  
  FindDialog::FindDialog(QWidget* parent=0):QDialog(parent=0)
  {
      label=new QLabel(tr("Find %what"));
      lineEdit=new lineEdit;
      label-&gt;setBuddy(lineEdit);
  
      caseCheckBox=new QCheckBox(tr("Match &amp;case"));
      backwardCheckBox=new QCheckBox(tr("search &amp;backward"));
  
      findButton=new QPushButton("&amp;Find");
      findButton-&gt;setDefault(true);
      findButton-&gt;setDefault(false);
  
      closeButton=new QPushButton(tr("close"));
  
  
      connect(lineEdit,SIGNAL(textchanged(const QString &amp;)),
              this,SLOT(enableFindbuton(const QString &amp;));
      connect(findButton,SIGNAL(clicked()),
          this,SLOT(findClicked());
      connect(closeButton,SIGNAL(clicked()),
          this,SLOT(close());
  
      QHBoxLayout* topLeftLayout=new QHBoxLayout;
      topLeftLayout-&gt;addWidget(label);
      topLeftLayout-&gt;addWidget(lineEdit);
  
      QVBoxLayout* leftLayout=new QVBoxLayout;
      leftLayout-&gt;addLayout(topLeftLayout);
      leftLayout-&gt;addWidget(caseCheckBox);
      leftLayout-&gt;addWidget(backwardCheckBox);
  
      QVBoxLayout* rightLayout=new QVBoxLayout;
      rightLayout-&gt;addWidget(findButton);
      rightLayout-&gt;addWidget(closeButton);
      rightLayout-&gt;addStretch();   //what the hell is this function?
  
      QHBoxLayout* mainlayout=new QHBoxLayout;
      mainlayout-&gt;addLayout(leftLayout);
      mainLayout-&gt;addLayout(rightLayout);
  
      setWindowTitle(tr("Find"));
      setFixedHeight(sizeHint().height());  
  
      }
  
  void FindDialog::findClicked()
  {
      QString text=lineEdit-&gt;text();
      Qt::CaseSensitivity cs=caseCheckBox-&gt;isChecked()?   Qt::CaseSensitive:Qt::CaseInsensitive;
  
      if(backwardCheckBox-&gt;isChecked()){
          emit findPrevious(text,cs);
      }else{
          emit findNext(text,cs);
      }
  }     
  
  void FindDialog::enableFindbuton(const QString &amp;text)
  {
      findButton-&gt;setEnabled(!text.isEmpty());
  }
  </code></pre>
  
  <p><strong>main.cpp</strong>:</p>
  
  <pre><code>#include"mainwindow.h"
  #include&lt;QApplication&gt;
  #include"finddialog.h"
  
  class FindDialog;
  int main(int argc,char*argv[])
  {
      QApplication app(argc,argv);
      MainWindow w;
      w.show();
      FindDialog* dialog=new FindDialog;
      dialog-&gt;show();
  
      return app.exec();
  }
  </code></pre>
  
  <p><strong>mainwindow.cpp</strong>:</p>
  
  <pre><code>#include "mainwindow.h"
  #include "ui_mainwindow.h"
  #include&lt;QObject&gt;
  
  MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
  {
      ui-&gt;setupUi(this);
  }
  
  MainWindow::~MainWindow()
  {
     delete ui;
  }
  </code></pre>
  
  <p>I am making a dialog window exactly like this:
  <img src="https://i.stack.imgur.com/yWXtO.png" alt="enter image description here">
  so that is the whole main structure of my code. Hope you can understand it.
  I'm so sorry that it is that long.</p>
  
  <p>I didn't use the "qmake" and "make" as the author did in the book. I directly use the Qt creator. And then the whole thing mess up....
  The two error messages look like this:</p>
  
  <pre><code>main.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl    FindDialog::FindDialog(class QWidget *)" (??0FindDialog@@QEAA@PEAVQWidget@@@Z) referenced in function main
  
  debug\test2.exe:-1: error: LNK1120: 1 unresolved externals
  </code></pre>