You aren't actually overriding the type function. Your int type()
function is non-const, while the class documentation shows that the virtual QGraphicsItem function is const. The constness needs to match for your function to override of the QGraphicsItem function.
If you have a C++11 compiler, you can specify override to ensure it is a compiler error if your function does not actually override a virtual method. As of Qt5, there is a macro Q_DECL_OVERRIDE
defined in QtGlobal which will become the override keyword for compilers that support it, or nothing for compilers that do not.
I also notice you're also checking item->type()==7
and item->type()==8
. In the version of Qt I have handy (4.7.2), those type values correspond to QGraphicsPixmapItem and QGraphicsTextItem, respectively. Are you sure those are the values you're looking for? I'd expect the comparisons to be item->type() == FotoGebouw::TypeFotoGebouw
and item->type() == FotoGebouw::TypeFotoPlantage
.