PDA

View Full Version : Getting Undefined Reference Error



A.H.M. Mahfuzur Rahman
21st June 2009, 01:17
I am getting the error:

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

What is the reason? The code is below:

mainwindow.h



#ifndef MAINWINDOW_H
#define MAINWINDOW_H

class MainArea;
class StartWindow;

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
MainWindow();
~MainWindow();
private slots:
void newGame();

private:

void setupActions();

MainArea *m_graphicsViewArea;
StartWindow *m_startWindow;
KTextEdit *m_textArea;

};

#endif // MAINWINDOW_H


mainwindow.cpp


#include "mainwindow.h"
#include "mainarea.h"
#include "startwindow.h"


//Constructor
MainWindow::MainWindow()
: QMainWindow()
{


m_graphicsViewArea = new MainArea(this);
m_startWindow = new StartWindow(this); //Here is the error
setCentralWidget(m_startWindow);
setWindowTitle("Mancala");

setupActions();

}


startwindow.h


#ifndef STARTWINDOW_H
#define STARTWINDOW_H

class StartWindow : public QGraphicsView{

Q_OBJECT

public:
StartWindow(QWidget *parent);

private:

QGraphicsSimpleTextItem *m_start_text;
};

#endif // STARTWINDOW_H


startwindow.cpp


#include "startwindow.h"

StartWindow::StartWindow(QWidget *parent)
: QGraphicsView(parent)
{

m_start_text = new QGraphicsSimpleTextItem("This is a collection of Mancala Games");

m_start_text->setFont( QFont("Comic Sans MS", 24, QFont::Bold) );

scene()->addItem(m_start_text);

}


Mahfuz

caduel
21st June 2009, 11:30
make sure startwindow.cpp is added to your .pro file; maybe you need to run qmake again?

nish
22nd June 2009, 03:12
#include <QGraphicsView> in startwindow