I am working at a university project with Qt version 4.7.2(I am using an old version because our teacher will use this version to review the project) on a Windows x86 machine but I have some problems while linking some function from the class Container to the class QListModelAdapter.
I've already tried running qmake again, clean and rebuild the project and deleting the build folder for building it from scratch but nothing of this worked, also checked my .pro file but seems like nothing wrong there.
qlistmodeladapter.h
#ifndef QLISTMODELADAPTER_H
#define QLISTMODELADAPTER_H
#include <QAbstractListModel>
#include "container.h"
class AddLayout;
class QListModelAdapter : public QAbstractListModel {
private:
Container<articolo>* model;
const AddLayout* insert;
public:
QListModelAdapter(QObject* = nullptr, const AddLayout* = nullptr);
~QListModelAdapter() override;
bool insertRows(int, int = 1, const QModelIndex& = QModelIndex()) override;
bool removeRows(int, int = 1, const QModelIndex& = QModelIndex()) override;
};
#endif
qlistmodeladapter.cpp
#include "qlistmodeladapter.h"
#include "container.h"
#include "addlayout.h"
#include <QFont>
QListModelAdapter::QListModelAdapter(QObject* parent, const AddLayout* ins) :
QAbstractListModel(parent),
model(new Container<articolo>()), insert(ins) {}
bool QListModelAdapter::removeRows(int begin, int count, const QModelIndex& parent) {
beginRemoveRows(parent, begin, begin + count - 1);
model->removeEl(begin);
endRemoveRows();
return true;
}
bool QListModelAdapter::insertRows(int begin, int count, const QModelIndex& parent) {
beginInsertRows(parent, begin, begin + count - 1);
articolo art = articolo(new Computer(insert->getNome()));
model->insertEl(art);
endInsertRows();
return true;
}
container.cpp
#include "container.h"
template<class T>
void Container<T>::insertEl(T& p)
{
if (maxSize == size)
{
increaseSize();
}
iteratore it = end();
*(it) = p;
size++;
}
template<class T>
void Container<T>::removeEl(int j)
{
if (j <= size)
{
iteratore it = begin();
for(int i = 0; i <= (j-1); i++)
{
it++;
}
delete it.punt;
iteratore aux = it;
it++;
for(int i = j; i < size-2; i++)
{
aux = it;
aux++;
it++;
}
size--;
}
}
container.h
#ifndef CONTAINER_H
#define CONTAINER_H
#include "items.h"
template<class T>
class Container
{
friend class iteratore;
private:
T* vector;
int size;
int maxSize;
public:
class iteratore {
// is defined correctly
};
Container(T* p = nullptr, int s = 0);//it is defined but not included
void removeEl(int);
void insertEl(T&);
};
#endif // CONTAINER_H
The incriminated function is removeEl and is where is get this error:
qlistmodeladapter.obj:-1: error: LNK2019: riferimento al simbolo esterno "public: void __cdecl Container<class articolo>::removeEl(int)" (?removeEl@?$Container@Varticolo@@@@QEAAXH@Z) non risolto nella funzione "public: virtual bool __cdecl QListModelAdapter::removeRows(int,int,class QModelIndex const &)" (?removeRows@QListModelAdapter@@UEAA_NHHAEBVQModelIndex@@@Z)
sorry but the language is set on Italian, the strange thing is that it works properly with insertEl so i don't know what to think.
I've already checked the .pro file so I'm not including it right now because there is a lot of code already.
Every help will be really appreciated, thank you a lot.