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:
Qt Code:
  1. bool AFile::operator==(AFile &file1) const
  2. {
  3. if(filePath!=file1.getFilePath()) //filepath is a QString
  4. return false;
  5. else
  6. return true;
  7. }
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:

Qt Code:
  1. usr/local/Trolltech/Qt-4.1.1/include/QtCore/qlist.h: In member function ‘int QList<T>::removeAll(const T&) [with T = AFile]’:
  2. video/AFileList.cpp:75: instantiated from here
  3. /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’
  4. video/AFile.h:22: note: candidates are: bool AFile::operator==(AFile&) const
  5. video/AFile.h:23: note: bool AFile::operator==(AFile*) const
  6. /usr/local/Trolltech/Qt-4.1.1/include/QtCore/qglobal.h:1266: note: bool operator==(QBool, bool)
  7. /usr/local/Trolltech/Qt-4.1.1/include/QtCore/qglobal.h:1267: note: bool operator==(bool, QBool)
  8. /usr/local/Trolltech/Qt-4.1.1/include/QtCore/qglobal.h:1268: note: bool operator==(QBool, QBool)
  9. /usr/local/Trolltech/Qt-4.1.1/include/QtCore/qchar.h:283: note: bool operator==(QChar, QChar)
  10. /usr/local/Trolltech/Qt-4.1.1/include/QtCore/qbytearray.h:421: note: bool operator==(const QByteArray&, const QByteArray&)
  11. /usr/local/Trolltech/Qt-4.1.1/include/QtCore/qbytearray.h:423: note: bool operator==(const QByteArray&, const char*)
  12. /usr/local/Trolltech/Qt-4.1.1/include/QtCore/qbytearray.h:425: note: bool operator==(const char*, const QByteArray&)
  13. /usr/local/Trolltech/Qt-4.1.1/include/QtCore/qstring.h:713: note: bool operator==(QString::Null, QString::Null)
  14. /usr/local/Trolltech/Qt-4.1.1/include/QtCore/qstring.h:714: note: bool operator==(QString::Null, const QString&)
  15. /usr/local/Trolltech/Qt-4.1.1/include/QtCore/qstring.h:715: note: bool operator==(const QString&, QString::Null)
  16. /usr/local/Trolltech/Qt-4.1.1/include/QtCore/qstring.h:733: note: bool operator==(const char*, const QString&)
  17. gmake[1]: *** [AFileList.o] Error 1
  18. gmake: *** [sub-src-make_default] Error 2
  19. *** Exited with status: 2 ***
To copy to clipboard, switch view to plain text mode 

thanks in advance!