#include <QWidget> and #include <QStyleOptionGraphicsItem> should fix the compile error you are getting.
常见错误: 头文件未包含
Render QGraphicsItem on QPixmap: aggregate 'QWidget w' has incomplete type and cannot be defined
原文:http://www.cnblogs.com/ranson7zop/p/7495157.html