I am quite new to Qt framework. I try to code a class that contains a 2D array whose data is supposed to be displayed in the main window (using QTableWidget, for example). The class has the following declaration:
// gridgame.h
template <int gsize_r,int gsize_c>
class GridGame : public QObject
{
    Q_OBJECT
private:
    char field[gsize_r][gsize_c];
public:
    GridGame();
    void setupConnect(QMainWindow & win);
signals:
    void onPrintStatus(char[gsize_r][gsize_c]);
};
The definition of the class is of course given in cpp file as follows:
//gridgame.cpp
#include "gridgame.h"
template <int gsize_r,int gsize_c>
GridGame<gsize_r,gsize_c>::GridGame()
{
    int i,j;
    for (i=0;i<gsize_r;++i)
        for (j=0;j<gsize_c;++j)
            field[i][j] = '-';
}
template <int gsize_r,int gsize_c>
void GridGame<gsize_r,gsize_c>::setupConnect(QMainWindow &win)
{
    connect(this,SIGNAL(onPrintStatus()),&win,SLOT(onRefresh()));
}
template <int gsize_r,int gsize_c>
void GridGame<gsize_r,gsize_c>::onPrintStatus(char[gsize_r][gsize_c]){
    emit field;
}
The class is used in main as follows:
#include <QtCore>
#include <QApplication>
#include <QObject>
#include "mainwindow.h"
#include "gridgame.cpp"
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    const int sizer = 5, sizec = 5;
    GridGame<sizer,sizec> gg;
    w.show();
    gg.printStatus();
    return a.exec();
}
Question: The code seems to compile ok, but I get the linker errors even if I do not call any function of the class (just have a declaration of a variable)
-1: error: undefined reference to `GridGame<5, 5>::metaObject() const'
-1: error: undefined reference to `GridGame<5, 5>::qt_metacast(char const*)'
-1: error: undefined reference to `GridGame<5, 5>::qt_metacall(QMetaObject::Call, int, void**)'
-1: error: error: ld returned 1 exit status
What might be the problem? I am using Qt Creator 3.6.1 and Qt library 5.6.0.
Thanks in advance for any help.
