I don't think qgraphicsitem_cast will work the way you are using it.

Check your pointer in debug mode:
Qt Code:
  1. BackgroundItem *myBackItem = qgraphicsitem_cast<BackgroundItem*>(graphicItems.at(i));
  2. Q_ASSERT(myBackItem);
To copy to clipboard, switch view to plain text mode 

Try static_cast instead.