Reputation: 5274
I am trying to create a chessboard. All the coins are transparent and the board is not. When I tried to get the clicked item using the function 'itemAt' it always returning the backGround item(that means the board). I am suspecting that due to the fact that the coins are transparent, they are not selected.
Upvotes: 4
Views: 1309
Reputation: 5274
I got the answer. I tried to get the event->pos()
. This will return the mouse click in the QGraphicsItem
's coordinates. So I should use event->scenePos()
.
Now I am getting it properly.
Upvotes: 3
Reputation: 12832
If you are using your own custom QGraphicsItem
then you may need to override shape()
,
If it's a plain QGraphicsPixmapItem
and it has an alpha mask, then you need to call setShapeMode()
.
Upvotes: 1