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
Code:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
class MainArea;
class StartWindow;
{
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
Code:
#include "mainwindow.h"
#include "mainarea.h"
#include "startwindow.h"
//Constructor
MainWindow::MainWindow()
{
m_graphicsViewArea = new MainArea(this);
m_startWindow = new StartWindow(this); //Here is the error
setCentralWidget(m_startWindow);
setWindowTitle("Mancala");
setupActions();
}
startwindow.h
Code:
#ifndef STARTWINDOW_H
#define STARTWINDOW_H
Q_OBJECT
public:
private:
};
#endif // STARTWINDOW_H
startwindow.cpp
Code:
#include "startwindow.h"
StartWindow
::StartWindow(QWidget *parent
){
m_start_text
->setFont
( QFont("Comic Sans MS",
24,
QFont::Bold) );
scene()->addItem(m_start_text);
}
Mahfuz
Re: Getting Undefined Reference Error
make sure startwindow.cpp is added to your .pro file; maybe you need to run qmake again?
Re: Getting Undefined Reference Error
#include <QGraphicsView> in startwindow