Results 1 to 3 of 3

Thread: Getting Undefined Reference Error

  1. #1
    Join Date
    Jun 2009
    Posts
    29
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Getting Undefined Reference Error

    I am getting the error:

    mainwindow.cpp:44: undefined reference to `StartWindow::StartWindow(QWidget*)

    What is the reason? The code is below:

    mainwindow.h
    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. class MainArea;
    5. class StartWindow;
    6.  
    7. class MainWindow : public QMainWindow
    8. {
    9. Q_OBJECT
    10.  
    11. public:
    12. MainWindow();
    13. ~MainWindow();
    14. private slots:
    15. void newGame();
    16.  
    17. private:
    18.  
    19. void setupActions();
    20.  
    21. MainArea *m_graphicsViewArea;
    22. StartWindow *m_startWindow;
    23. KTextEdit *m_textArea;
    24.  
    25. };
    26.  
    27. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

    mainwindow.cpp
    Qt Code:
    1. #include "mainwindow.h"
    2. #include "mainarea.h"
    3. #include "startwindow.h"
    4.  
    5.  
    6. //Constructor
    7. MainWindow::MainWindow()
    8. {
    9.  
    10.  
    11. m_graphicsViewArea = new MainArea(this);
    12. m_startWindow = new StartWindow(this); //Here is the error
    13. setCentralWidget(m_startWindow);
    14. setWindowTitle("Mancala");
    15.  
    16. setupActions();
    17.  
    18. }
    To copy to clipboard, switch view to plain text mode 

    startwindow.h
    Qt Code:
    1. #ifndef STARTWINDOW_H
    2. #define STARTWINDOW_H
    3.  
    4. class StartWindow : public QGraphicsView{
    5.  
    6. Q_OBJECT
    7.  
    8. public:
    9. StartWindow(QWidget *parent);
    10.  
    11. private:
    12.  
    13. QGraphicsSimpleTextItem *m_start_text;
    14. };
    15.  
    16. #endif // STARTWINDOW_H
    To copy to clipboard, switch view to plain text mode 

    startwindow.cpp
    Qt Code:
    1. #include "startwindow.h"
    2.  
    3. StartWindow::StartWindow(QWidget *parent)
    4. : QGraphicsView(parent)
    5. {
    6.  
    7. m_start_text = new QGraphicsSimpleTextItem("This is a collection of Mancala Games");
    8.  
    9. m_start_text->setFont( QFont("Comic Sans MS", 24, QFont::Bold) );
    10.  
    11. scene()->addItem(m_start_text);
    12.  
    13. }
    To copy to clipboard, switch view to plain text mode 

    Mahfuz

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Getting Undefined Reference Error

    make sure startwindow.cpp is added to your .pro file; maybe you need to run qmake again?

  3. #3
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Getting Undefined Reference Error

    #include <QGraphicsView> in startwindow

Similar Threads

  1. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  2. MS Sql native driver??
    By LordQt in forum Qt Programming
    Replies: 4
    Last Post: 9th October 2007, 13:41
  3. error undefined reference ...............
    By amit_pansuria in forum Qt Programming
    Replies: 2
    Last Post: 8th June 2007, 14:28
  4. how to correctly compile threads support?
    By srhlefty in forum Installation and Deployment
    Replies: 9
    Last Post: 25th June 2006, 19:15
  5. Strange error while using Q3Canvas
    By Kapil in forum Newbie
    Replies: 13
    Last Post: 15th June 2006, 19:36

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.