Situation:
I have a Dialog
class in QT on which I draw a raster of squares. The squares are implemented in the MySquare
class (MySquare: QGraphicsItem
).
Inside the MySquare there are a number of functions (mysquare.h protected: )
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void keyPressEvent(QKeyEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
When I click on a square it gives me the relative coordinates of the square using the following function.
void MySquare::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
update();
QGraphicsItem::mousePressEvent(event);
qDebug() << "mouse Pressed";
qDebug() << "coordinates:";
qDebug() << "X:"<< x/w << " Y:" << y/h ;
}
Where x and y are the x and y position in the raster and w and h stand for width and height
However my question is how can I let my Dialog class know what square was clicked on?