Hehehe I have a valid solution:
Square *square=map.getSquare(i,j);
zoomedPoly<<square->left()*zoom
<<square->up()*zoom
<<square->right()*zoom
<<square->down()*zoom;
if(region.contains(cursorPos)){
painter.setPen(Qt::red);
selectedSquarePosX=i; selectedSquarePosY=j;
}
Square *square=map.getSquare(i,j);
QPolygon zoomedPoly;
zoomedPoly<<square->left()*zoom
<<square->up()*zoom
<<square->right()*zoom
<<square->down()*zoom;
QRegion region(zoomedPoly);
if(region.contains(cursorPos)){
painter.setPen(Qt::red);
selectedSquarePosX=i; selectedSquarePosY=j;
}
To copy to clipboard, switch view to plain text mode
Square inherits from QPolygon and has defined up(), right(), down(), left() as points of the polygon.
Anyway is there a better solution for it?
Bookmarks