Linker error with qt

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Xx r3negade
    New Member
    • Apr 2008
    • 39

    #1

    Linker error with qt

    I am new to Qt. I created a basic form with 4 buttons: btn_DoSomething , btn_Clear, btn_About, btn_Browse. I used qmake-qt4 to generate the header file containing my form info (ui_myqtapp.h).

    I then created this header file:
    Code:
    // myqtapp.h:
    
    #ifndef MYQTAPP_H
    #define MYQTAPP_H
    
    #include "ui_myqtapp.h"
    
    class myQtApp : public QWidget, private Ui::frmMain
    {
        Q_OBJECT
        public:
            myQtApp(QWidget* parent = 0);
        public slots:
            void getPath();
            void doSomething();
            void clear();
            void about();
    };
    
    #endif
    Looks good so far, right? Then I implemented the functions defined in the slots, and connected them to the 4 buttons:
    Code:
    // myqtapp.cpp:
    
    #include <QtGui>
    // if we include <QtGui> there is no need to include every class used: <QString>, <QFileDialog>,...
    #include "myqtapp.h"
    
    myQtApp::myQtApp( QWidget* parent )
    {
        setupUi(this); // Set up the GUI
    
        // signals / slots mechanisms in action -> link a action in the GUI to a subroutine in this class
        connect( btn_Browse,    SIGNAL(clicked()),  this,   SLOT(getPath())     );
        connect(btn_DoSomething,SIGNAL(clicked()),  this,   SLOT(doSomething()) );
        connect( btn_Clear,     SIGNAL(clicked()),  this,   SLOT(clear())       );
        connect( btn_About,     SIGNAL(clicked()),  this,   SLOT(about())       );
    }
    Finally, I created the "main" file:
    Code:
    // main.cpp:
    
    #include <QApplication>
    #include "myqtapp.h"
    int main(int argc, char* argv[])
    
    {
        QApplication app(argc, argv);
    
        myQtApp* dialog = new myQtApp;
    
        dialog->show();
        return app.exec();
    }
    It compiles fine but I get this linker error:
    Code:
    /home/jBrandt/Code/qt/myqtapp.cpp|5|undefined reference to `vtable for myQtApp'|
    in line 5 of myqtapp.cpp (myQtApp::myQtA pp( QWidget* parent ))
  • Xx r3negade
    New Member
    • Apr 2008
    • 39

    #2
    I know I'm not the only one here who uses Qt. I need an answer.

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      A quick google turned up this http://doc.trolltech.com/3.1/commonp...html#linkerror

      Comment

      Working...