Hi!
I've a list of a custom items and I have implemented function == in my code but it doesn't works!

This is my code:

Qt Code:
  1. #ifndef RUTA_H
  2. #define RUTA_H
  3.  
  4. #include <QtCore>
  5.  
  6. class Ruta
  7. {
  8. public:
  9. Ruta();
  10. void setNum(int r);
  11. int getNum();
  12. bool operator ==(const Ruta & r) const;
  13.  
  14. private:
  15. int num;
  16. };
  17. #endif // RUTA_H
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #include "ruta.h"
  2.  
  3. Ruta::Ruta()
  4. {
  5. }
  6.  
  7. void Ruta::setNum(int r)
  8. {
  9. num = r;
  10. }
  11.  
  12. int Ruta::getNum()
  13. {
  14. return num;
  15. }
  16.  
  17. bool Ruta::operator ==(const Ruta & r) const
  18. {
  19. return(r.num == this->num);
  20. }
To copy to clipboard, switch view to plain text mode 

The main function is:
Qt Code:
  1. Ruta *a = new Ruta();
  2. Ruta *b = new Ruta();
  3.  
  4. a->setNum(1);
  5. b->setNum(1);
  6.  
  7. if(a == b)
  8. qDebug("ok!");
  9. else
  10. qDebug("no");
To copy to clipboard, switch view to plain text mode 

And the output is:
Qt Code:
  1. no
To copy to clipboard, switch view to plain text mode 

I don't know what can I do, because I need It to use a "indexOf" function in a QList<Ruta*>