Hi everyone,
I have created a list QList <AFile> list;
Now, I know that in order to use the removeAll() method of the list, the operator==()
must be implemented in the class AFile. I did implement it like this:
bool AFile::operator==(AFile &file1) const
{
if(filePath!=file1.getFilePath()) //filepath is a QString
return false;
else
return true;
}
bool AFile::operator==(AFile &file1) const
{
if(filePath!=file1.getFilePath()) //filepath is a QString
return false;
else
return true;
}
To copy to clipboard, switch view to plain text mode
is there anything wrong with it?
when i use the removeAll() the compiler shows the follow errors:
usr/local/Trolltech/Qt-4.1.1/include/QtCore/qlist.h: In member function ‘int QList<T>::removeAll(const T&) [with T = AFile]’:
video/AFileList.cpp:75: instantiated from here
/usr/local/Trolltech/Qt-4.1.1/include/QtCore/qlist.h:549: error: no match for ‘operator==’ in ‘(n <unknown operator> ((QList<AFile>::Node*)((QList<AFile>*)this)->QList<AFile>::<anonymous>.QList<AFile>::<anonymous union>::p. QListData::at(i)))->QList<T>::Node::t [with T = AFile]() == t’
video/AFile.h:22: note: candidates are: bool AFile::operator==(AFile&) const
video/AFile.h:23: note: bool AFile::operator==(AFile*) const
/usr/local/Trolltech/Qt-4.1.1/include/QtCore/qglobal.h:1266: note: bool operator==(QBool, bool)
/usr/local/Trolltech/Qt-4.1.1/include/QtCore/qglobal.h:1267: note: bool operator==(bool, QBool)
/usr/local/Trolltech/Qt-4.1.1/include/QtCore/qglobal.h:1268: note: bool operator==(QBool, QBool)
/usr
/local
/Trolltech
/Qt
-4.1.1
/include
/QtCore
/qchar.
h:283: note
: bool operator
==(QChar,
QChar) /usr/local/Trolltech/Qt-4.1.1/include/QtCore/qbytearray.h:421: note: bool operator==(const QByteArray&, const QByteArray&)
/usr/local/Trolltech/Qt-4.1.1/include/QtCore/qbytearray.h:423: note: bool operator==(const QByteArray&, const char*)
/usr/local/Trolltech/Qt-4.1.1/include/QtCore/qbytearray.h:425: note: bool operator==(const char*, const QByteArray&)
/usr
/local
/Trolltech
/Qt
-4.1.1
/include
/QtCore
/qstring.
h:713: note
: bool operator
==(QString::Null,
QString::Null) /usr
/local
/Trolltech
/Qt
-4.1.1
/include
/QtCore
/qstring.
h:714: note
: bool operator
==(QString::Null,
const QString
&) /usr
/local
/Trolltech
/Qt
-4.1.1
/include
/QtCore
/qstring.
h:715: note
: bool operator
==(const QString
&,
QString::Null) /usr/local/Trolltech/Qt-4.1.1/include/QtCore/qstring.h:733: note: bool operator==(const char*, const QString&)
gmake[1]: *** [AFileList.o] Error 1
gmake: *** [sub-src-make_default] Error 2
*** Exited with status: 2 ***
usr/local/Trolltech/Qt-4.1.1/include/QtCore/qlist.h: In member function ‘int QList<T>::removeAll(const T&) [with T = AFile]’:
video/AFileList.cpp:75: instantiated from here
/usr/local/Trolltech/Qt-4.1.1/include/QtCore/qlist.h:549: error: no match for ‘operator==’ in ‘(n <unknown operator> ((QList<AFile>::Node*)((QList<AFile>*)this)->QList<AFile>::<anonymous>.QList<AFile>::<anonymous union>::p. QListData::at(i)))->QList<T>::Node::t [with T = AFile]() == t’
video/AFile.h:22: note: candidates are: bool AFile::operator==(AFile&) const
video/AFile.h:23: note: bool AFile::operator==(AFile*) const
/usr/local/Trolltech/Qt-4.1.1/include/QtCore/qglobal.h:1266: note: bool operator==(QBool, bool)
/usr/local/Trolltech/Qt-4.1.1/include/QtCore/qglobal.h:1267: note: bool operator==(bool, QBool)
/usr/local/Trolltech/Qt-4.1.1/include/QtCore/qglobal.h:1268: note: bool operator==(QBool, QBool)
/usr/local/Trolltech/Qt-4.1.1/include/QtCore/qchar.h:283: note: bool operator==(QChar, QChar)
/usr/local/Trolltech/Qt-4.1.1/include/QtCore/qbytearray.h:421: note: bool operator==(const QByteArray&, const QByteArray&)
/usr/local/Trolltech/Qt-4.1.1/include/QtCore/qbytearray.h:423: note: bool operator==(const QByteArray&, const char*)
/usr/local/Trolltech/Qt-4.1.1/include/QtCore/qbytearray.h:425: note: bool operator==(const char*, const QByteArray&)
/usr/local/Trolltech/Qt-4.1.1/include/QtCore/qstring.h:713: note: bool operator==(QString::Null, QString::Null)
/usr/local/Trolltech/Qt-4.1.1/include/QtCore/qstring.h:714: note: bool operator==(QString::Null, const QString&)
/usr/local/Trolltech/Qt-4.1.1/include/QtCore/qstring.h:715: note: bool operator==(const QString&, QString::Null)
/usr/local/Trolltech/Qt-4.1.1/include/QtCore/qstring.h:733: note: bool operator==(const char*, const QString&)
gmake[1]: *** [AFileList.o] Error 1
gmake: *** [sub-src-make_default] Error 2
*** Exited with status: 2 ***
To copy to clipboard, switch view to plain text mode
thanks in advance!
Bookmarks