Results 1 to 3 of 3

Thread: Modal Dialog unresolved external symbol

  1. #1
    Join Date
    May 2014
    Posts
    13
    Qt products
    Qt5
    Platforms
    Windows

    Default Modal Dialog unresolved external symbol

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Modal Dialog unresolved external symbol

    Did you add Address dialog to .pro file?
    Qt 5.3 Opensource & Creator 3.1.2

  3. #3
    Join Date
    May 2014
    Posts
    13
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Modal Dialog unresolved external symbol

    Here is the pro file:

    Qt Code:
    1. #-------------------------------------------------
    2. #
    3. # Project created by QtCreator 2014-06-15T14:15:32
    4. #
    5. #-------------------------------------------------
    6.  
    7. QT += core gui
    8.  
    9. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    10.  
    11. TARGET = ListView
    12. TEMPLATE = app
    13.  
    14.  
    15. SOURCES += main.cpp\
    16. mainwindow.cpp \
    17. addressdialog.cpp
    18.  
    19. HEADERS += mainwindow.h \
    20. addressdialog.h
    21.  
    22. FORMS += mainwindow.ui \
    23. addressdialog.ui
    To copy to clipboard, switch view to plain text mode 


    Added after 41 minutes:


    This is really frustrating!!! I closed down Qt Creator, deleted the build directory and the pro.user file. Then I restarted Qt Creator and did a build. It compiled fine and the application ran without issue. I don't know what is the problem with Qt Creator but this should not be happening. I suppose all that matters at this point is that it is now working. I spent 6 hours yesterday struggling with this. Is there a valid reason why Qt Creator does this? I have experienced this before. It just didn't dawn on me this could be what I needed to do this time.
    Last edited by gpuckett; 16th June 2014 at 14:41.

Similar Threads

  1. unresolved external symbol with qwt3d
    By pospiech in forum Qt Programming
    Replies: 6
    Last Post: 2nd February 2016, 21:47
  2. Help - LNK2019: Unresolved external symbol
    By marc2050 in forum Newbie
    Replies: 3
    Last Post: 17th May 2011, 01:29
  3. unresolved external symbol
    By gridolfi in forum Qt Programming
    Replies: 1
    Last Post: 8th September 2009, 17:58
  4. unresolved external symbol
    By tgreaves in forum Qt Programming
    Replies: 2
    Last Post: 16th January 2009, 19:49
  5. Unresolved External Symbol
    By munna in forum General Discussion
    Replies: 1
    Last Post: 10th May 2006, 19:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.