Hi, I'm trying to get up a class for a Qt program, but it gives me this errors:
Error 1 error C2662: 'Square::left' : cannot convert 'this' pointer from 'const Square' to 'Square &' c:\Chus\konstructor\src\Square.cpp 6
Error 2 error C2662: 'Square::up' : cannot convert 'this' pointer from 'const Square' to 'Square &' c:\Chus\konstructor\src\Square.cpp 6
Error 3 error C2662: 'Square::right' : cannot convert 'this' pointer from 'const Square' to 'Square &' c:\Chus\konstructor\src\Square.cpp 6
Error 4 error C2662: 'Square::down' : cannot convert 'this' pointer from 'const Square' to 'Square &' c:\Chus\konstructor\src\Square.cpp 6
The class code is:
Square.h:
Qt Code:
  1. #pragma once
  2.  
  3. #include <QPolygon>
  4.  
  5. class Square:public QPolygon{
  6. public:
  7. Square();
  8. Square(const Square &rhs);
  9. Square(const QPoint left,const QPoint up,const QPoint right,const QPoint down);
  10.  
  11. QPoint left(){return data()[left];}
  12. QPoint up(){return data()[UP];}
  13. QPoint right(){return data()[right];}
  14. QPoint down(){return data()[DOWN];}
  15. void setLeft(QPoint left);
  16. void setUp(QPoint up);
  17. void setRight(QPoint right);
  18. void setDown(QPoint down);
  19. private:
  20. enum Points {LEFT=0,UP=1,RIGHT=2,DOWN=3};
  21. };
To copy to clipboard, switch view to plain text mode 
Square.cpp:
Qt Code:
  1. #include "Square.h"
  2.  
  3. Square::Square():QPolygon(4){}
  4.  
  5. Square::Square(const Square &rhs){
  6. Square(rhs.left(),rhs.up(),rhs.right(),rhs.down());
  7. }
  8.  
  9. Square::Square(const QPoint left,const QPoint up,const QPoint right,const QPoint down){
  10. // Añadir los puntos dados al constructor
  11. setPoints(4, // Número de puntos del polÃ*gono
  12. left.x(),left.y(), // Izquierda
  13. up.x(),up.y(), // Arriba
  14. right.x(),right.y(), // Derecha
  15. down.x(),down.y() // Abajo
  16. );
  17. }
  18.  
  19. void Square::setLeft(QPoint left){
  20. setPoint(LEFT,left);
  21. }
  22.  
  23. void Square::setUp(QPoint up){
  24. setPoint(UP,up);
  25. }
  26.  
  27. void Square::setRight(QPoint right){
  28. setPoint(RIGHT,right);
  29. }
  30.  
  31. void Square::setDown(QPoint down){
  32. setPoint(DOWN,down);
  33. }
To copy to clipboard, switch view to plain text mode 
Thank's for the help

NOTE: In lines 11, 13 appears [left] and [right] it's [L EFT] and [R IGHT] in my code. I don't know why it converts to lowercase on copy&paste.