PDA

View Full Version : Compiling error



vfernandez
9th March 2007, 20:19
I'm getting this compiling error but I can't find the problem. Any ideas?


g++ -c -pipe -g -pg -Wall -W -D_REENTRANT -DALLOW_LOCALFILESYSTEM -DKDE_INTEGRATION -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/lib/qt4/mkspecs/linux-g++ -I. -I/usr/lib/qt4/include/QtCore -I/usr/lib/qt4/include/QtCore -I/usr/lib/qt4/include/QtGui -I/usr/lib/qt4/include/QtGui -I/usr/lib/qt4/include -I. -I. -o errorlog.o errorlog.cpp
/usr/lib/qt4/include/QtCore/qobject.h: In copy constructor 'GenericError::GenericError(const GenericError&)':
genericerror.h:5: instantiated from 'void QList<T>::append(const T&) [with T = GenericError]'
errorlog.cpp:15: instantiated from here
/usr/lib/qt4/include/QtCore/qobject.h:277: error: 'QObject::QObject(const QObject&)' is private
genericerror.h:5: error: within this context
/usr/lib/qt4/include/QtCore/qlist.h: In member function 'void QList<T>::append(const T&) [with T = GenericError]':
/usr/lib/qt4/include/QtCore/qlist.h:403: note: synthesized method 'GenericError::GenericError(const GenericError&)' first required here
/usr/lib/qt4/include/QtCore/qlist.h: In member function 'int QList<T>::removeAll(const T&) [with T = GenericError]':
errorlog.cpp:22: instantiated from here
/usr/lib/qt4/include/QtCore/qlist.h:558: error: no match for 'operator==' in '(n <unknown operator> ((QList<GenericError>::Node*)((QList<GenericError>*)this)->QList<GenericError>::<anonymous>.QList<GenericError>::<anonymous union>::p. QListData::at(i)))->QList<T>::Node::t [with T = GenericError]() == t'
/usr/lib/qt4/include/QtCore/qglobal.h:1375: note: candidates are: bool operator==(QBool, bool)
/usr/lib/qt4/include/QtCore/qglobal.h:1376: note: bool operator==(bool, QBool)
/usr/lib/qt4/include/QtCore/qglobal.h:1377: note: bool operator==(QBool, QBool)
/usr/lib/qt4/include/QtCore/qchar.h:285: note: bool operator==(QChar, QChar)
/usr/lib/qt4/include/QtCore/qbytearray.h:433: note: bool operator==(const QByteArray&, const QByteArray&)
/usr/lib/qt4/include/QtCore/qbytearray.h:435: note: bool operator==(const QByteArray&, const char*)
/usr/lib/qt4/include/QtCore/qbytearray.h:437: note: bool operator==(const char*, const QByteArray&)
/usr/lib/qt4/include/QtCore/qstring.h:755: note: bool operator==(QString::Null, QString::Null)
/usr/lib/qt4/include/QtCore/qstring.h:756: note: bool operator==(QString::Null, const QString&)
/usr/lib/qt4/include/QtCore/qstring.h:757: note: bool operator==(const QString&, QString::Null)
/usr/lib/qt4/include/QtCore/qstring.h:784: note: bool operator==(const char*, const QString&)
/usr/lib/qt4/include/QtCore/qhash.h:148: note: bool operator==(const QHashDummyValue&, const QHashDummyValue&)
/usr/lib/qt4/include/QtCore/qobject.h: In member function 'GenericError& GenericError::operator=(const GenericError&)':
genericerror.h:5: instantiated from 'void QList<T>::node_construct(QList<T>::Node*, const T&) [with T = GenericError]'
/usr/lib/qt4/include/QtCore/qlist.h:401: instantiated from 'void QList<T>::append(const T&) [with T = GenericError]'
errorlog.cpp:15: instantiated from here
/usr/lib/qt4/include/QtCore/qobject.h:277: error: 'QObject& QObject::operator=(const QObject&)' is private
genericerror.h:5: error: within this context
/usr/lib/qt4/include/QtCore/qlist.h: In member function 'void QList<T>::node_construct(QList<T>::Node*, const T&) [with T = GenericError]':
/usr/lib/qt4/include/QtCore/qlist.h:316: note: synthesized method 'GenericError& GenericError::operator=(const GenericError&)' first required here
make: *** [errorlog.o] Error 1

errorlog.h

#include <QList>
#include "genericerror.h"

class ErrorLog : public QObject
{
Q_OBJECT

public:
ErrorLog(QObject *parent = 0);

QList<GenericError> errorList();
void registerError(const GenericError& error);
void removeError(const GenericError& error);
void clear();

signals:
void errorHappened(const GenericError& error);
void errorFixed(const GenericError& error);

private:
QList<GenericError> m_errorList;
};

errorlog.cpp

ErrorLog::ErrorLog(QObject *parent)
: QObject(parent)
{
}


QList<GenericError> ErrorLog::errorList()
{
return m_errorList;
}


void ErrorLog::registerError(const GenericError& error)
{
m_errorList.append(error);
emit errorHappened(error);
}


void ErrorLog::removeError(const GenericError& error)
{
m_errorList.removeAll(error);
emit errorFixed(error);
}


void ErrorLog::clear()
{
m_errorList.clear();
}

genericerror.h

#include <QObject>
#include <QString>
#include "apachecontext.h"

class GenericError : public QObject
{
Q_OBJECT

public:
enum Severity { NoError, Info, Warning, Error, Critical };

GenericError(QObject *parent = 0);

virtual GenericError::Severity severity() const;
virtual void setSeverity(Severity severity);
virtual QString title() const;
virtual void setTitle(const QString& title);
virtual QString description() const;
virtual void setDescription(const QString& description);
virtual VirtualHostId virtualHost() const;
virtual void setVirtualHost(VirtualHostId vHost);
virtual QString filePath() const;
virtual void setFilePath(const QString& filePath);
virtual int lineNumber() const;
virtual void setLineNumber(int lineNo);
virtual bool canAutoFix() const;
virtual bool canWorkIt() const;
virtual bool canComment() const;
virtual bool canRemove() const;
virtual bool autoFix();
virtual bool workIt();
virtual bool comment();
virtual bool remove();

protected:
Severity m_severity;
QString m_title;
QString m_description;
VirtualHostId m_vHost;
QString m_filePath;
int m_lineNumber;
};

ChristianEhrlicher
9th March 2007, 20:36
You can't copy a QObject - and this is what you implicit do when you define a QList<QObject>.
You can use a QList<QObject*> or not derive from QObject.

vfernandez
9th March 2007, 21:02
Ok, I've made it not being a QObject and implemented the operator==() and now it works. Thanks.