I am trying to design a modal dialog that will perform a search on a database and allow the user to select an item and then return it back to the calling program. This is my first attempt at producing a dialog and must be doing something very basic wrong. I have set up a simple project in Qt Creator. It has a main window with a single button. When I click on the button I want to bring up the dialog. For the moment I just want the dialog to come up and go away when I click cancel. When I try to build the project I am getting an unresolved external symbol. I have tried a little of everything. Being fairly new to Qt and C++ this just doesn't make sense to me.

I have the main window and the dialog set up in forms.

The main window has the following header:

Qt Code:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. #include <QMainWindow>
  5.  
  6. namespace Ui {
  7. class MainWindow;
  8. }
  9.  
  10. class MainWindow : public QMainWindow
  11. {
  12. Q_OBJECT
  13.  
  14. public:
  15. explicit MainWindow(QWidget *parent = 0);
  16. ~MainWindow();
  17.  
  18. public slots:
  19. void doAddressSearch();
  20.  
  21. private:
  22. Ui::MainWindow *ui;
  23. };
  24.  
  25. #endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode 

Here is the main window code:

Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3. #include "addressdialog.h"
  4.  
  5. MainWindow::MainWindow(QWidget *parent) :
  6. QMainWindow(parent),
  7. ui(new Ui::MainWindow)
  8. {
  9. ui->setupUi(this);
  10. QObject::connect(ui->addressSearchButton, SIGNAL(clicked()), this, SLOT(doAddressSearch()));
  11. }
  12.  
  13. MainWindow::~MainWindow()
  14. {
  15. delete ui;
  16. }
  17.  
  18. void MainWindow::doAddressSearch()
  19. {
  20. AddressDialog *addrDialog = new AddressDialog(this);
  21. addrDialog->show();
  22. }
To copy to clipboard, switch view to plain text mode 

The dialog header has:

Qt Code:
  1. #ifndef ADDRESSDIALOG_H
  2. #define ADDRESSDIALOG_H
  3.  
  4. #include <QDialog>
  5.  
  6. namespace Ui {
  7. class AddressDialog;
  8. }
  9.  
  10. class AddressDialog : public QDialog
  11. {
  12. Q_OBJECT
  13.  
  14. public:
  15. explicit AddressDialog(QWidget *parent = 0);
  16. ~AddressDialog();
  17.  
  18. private:
  19. Ui::AddressDialog *ui;
  20. };
  21.  
  22. #endif // ADDRESSDIALOG_H
To copy to clipboard, switch view to plain text mode 

And here is the dialog code:

Qt Code:
  1. #include "addressdialog.h"
  2. #include "ui_addressdialog.h"
  3.  
  4. AddressDialog::AddressDialog(QWidget *parent) :
  5. QDialog(parent),
  6. ui(new Ui::AddressDialog)
  7. {
  8. ui->setupUi(this);
  9. QDialog::connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
  10. }
  11.  
  12. AddressDialog::~AddressDialog()
  13. {
  14. delete ui;
  15. }
To copy to clipboard, switch view to plain text mode 

When I perform the build I get:

mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall AddressDialog::AddressDialog(class QWidget *)" (??0AddressDialog@@QAE@PAVQWidget@@@Z) referenced in function "public: void __thiscall MainWindow::doAddressSearch(void)" (?doAddressSearch@MainWindow@@QAEXXZ)
What am I doing wrong?