[SOLVED] Problem when create an Object : Undefiner reference
-
Hi all,
i don't understand the problem becuse the "undefine references" error s tu approssimative for debug and in my code is all defined but:
@
QList<Oggetto*> InterfacciaDataModel::convertitore(QList<MeteoLocale> lista){
QList<Oggetto*> listToReturn;for(int i=0; i < lista.count(); i++) {
Oggetto oggetto(lista.at(i).property); // here there are an error: undefined reference toOggetto::Oggetto(QHash<QString, QString>)' listToReturn.append(&oggetto); } // and here i have the same error but for destructor: undefined reference to
Oggetto::~Oggetto()'return listToReturn;
}
@in my .h file of Oggetto i define both method:
@
#include <QObject>
#include <QHash>class Oggetto: public QObject {
Q_OBJECT
public:
Oggetto();
Oggetto(QHash<QString, QString> param);
virtual ~Oggetto();QHash<QString, QString> property;
}
@and avery one can see the definition in the .cpp file:
@#include "Oggetto.h"
Oggetto::Oggetto(QHash<QString, QString> param) {
// TODO Auto-generated constructor stub
this->property(param);
}Oggetto::Oggetto(){
}
Oggetto::~Oggetto() {
// TODO Auto-generated destructor stub
}
@anione know why i have this error??
regards to all
-
Try re-running qmake, and rebuilding. I think you added Q_OBJECT later on. Q_OBJECT defines some methods, the implementation of which will be auto-generated by moc. However, moc is probably not ran on your header. It is those methods that are missing, I think.
-
Try removing moc_* files, or removing your .h and .cpp file from project and then adding them back.
Like Andre said, this is very likely a qmake related issue, and cleaning all you build files manually should fix it.
-
I have solved problem deleting project and re import all class in a new object but i have see in the includ of the header:
@HEADERS +=
$$BASEDIR/src/DataModelEInterfaccia/Interfaccia/InterfacciaDataModel.h
$$BASEDIR/src/DataModelEInterfaccia/Interfaccia/Oggetto.h
$$BASEDIR/src/DataModelEInterfaccia/MeteoLocaleDataModel/MeteoLocale.h
$$BASEDIR/src/DatabaseSQL/SQLConnector.h
$$BASEDIR/src/HttpRequest/HttpRequestXML.h
$$BASEDIR/src/HttpRequest/md5.h
$$BASEDIR/src/IlMeteo.hpp
$$BASEDIR/src/Parsing/XMLSitForeMeteoLocale.h
$$BASEDIR/src/ScreenView/MainScreenView.h
$$BASEDIR/src/System/OtherFunctionCacolator.h
$$BASEDIR/src/System/SystemConfig.h@now are present in the iold project missing... i think that this is the problem.. Tanks to all!! :)