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;
{
Q_OBJECT
public:
MainWindow();
~MainWindow();
private slots:
void newGame();
private:
void setupActions();
MainArea *m_graphicsViewArea;
StartWindow *m_startWindow;
KTextEdit *m_textArea;
};
#endif // 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
To copy to clipboard, switch view to plain text mode
mainwindow.cpp
#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();
}
#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();
}
To copy to clipboard, switch view to plain text mode
startwindow.h
#ifndef STARTWINDOW_H
#define STARTWINDOW_H
Q_OBJECT
public:
private:
};
#endif // 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
To copy to clipboard, switch view to plain text mode
startwindow.cpp
#include "startwindow.h"
StartWindow
::StartWindow(QWidget *parent
){
m_start_text
->setFont
( QFont("Comic Sans MS",
24,
QFont::Bold) );
scene()->addItem(m_start_text);
}
#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);
}
To copy to clipboard, switch view to plain text mode
Mahfuz
Bookmarks