What leads to incomplete types? (QGraphicsItem: Source or target has incomplete type)

后端 未结 2 1813
执念已碎
执念已碎 2020-12-19 22:47

I have a custom QGraphicsItem, that (among other things) changed the cursor to an open hand when clicked, using the standard procedure as described in the Qt documentation.

2条回答
  •  不知归路
    2020-12-19 23:48

    Forward declaration is usually fine in your headers, just make sure you include the class' header in your corresponding code file at the top (e.g. #include "itemsource.h").

    In response to the edit: If I am sure I've included my own headers correctly and I'm still getting incomplete type errors, then the next step would be to change #include for the whole Qt package. Unless there is a clearly identifiable benefit I always favour including the package completely. It just makes sure the inner dependencies of that package are satisfied.

    And finally, in Qt 4.x it appears QGraphicsPixmapItem is in QtGui but has been moved out to QtWidgets in 5.x. So if you're using 4 try replacing #include with #include and for 5 try #include .

提交回复
热议问题