Listing 2. Handling Collisions

QCanvasItem* item;
QCanvasItemList l = head->collisions(FALSE);
for (QCanvasItemList::Iterator it=l.begin();

   item = *it;
   // check if snake hit target
   if ( (item->rtti()== 1500 ) &&
      (item->collidesWith(head)) ) {
          // do something
          return;
   }
   // check if snake hit wall
   if ( (item->rtti()== 1600) &&
      (item->collidesWith(head)) ) {
          // do something
          return;
   }
}