There isn't a QGridLayout used, but I assume you already know that.

The widget is devided into several target squares, each 80x80.
A position is calculated by using the piece location. This is done with the following function:

Qt Code:
  1. const QRect PuzzleWidget::targetSquare(const QPoint &position) const
  2. {
  3. return QRect(position.x()/80 * 80, position.y()/80 * 80, 80, 80);
  4. }
To copy to clipboard, switch view to plain text mode 

If you look at the code, you'll see several lists, one for the pieces themselves, one for the position, etc...
When you drop a piece, the location and the piece are added to these lists. Then when you select a piece and move it around, this location is used to calculate if you're on the target rect or not.