我有一个自定义QGraphicsItem,其中(除其他外)使用Qt文档中描述的标准过程将光标更改为单击时打开的手.这在过去两周左右的时间里运作良好.昨天,我在课堂上改变了一些东西.最重要的是,我现在直接从QGraphicsPixmapItem继承而不是QGraphicsItem.
在某些时候我开始得到以下错误(部分是我自己的翻译):
C664:将参数1从'Qt :: CursorShape'转换为'const QCursor&'是不可能的.来源或目标的类型不完整.
我现在试图弄清楚为什么我的项目有一个不完整的类型.不幸的是,当这个问题开始发生时,我无法回溯.改变后的基类是我唯一的猜测,但我真的想不出这是怎么回事.在谷歌搜索错误之后,我找到了一些示例,其中类的成员有些不明确,但我在声明中找不到错误.所以,这是标题,万一我错过了一些东西:
#include <QGraphicsPixmapItem>
class Collection;
class ItemSource;
class PhotoItem : public QGraphicsPixmapItem
{
public:
PhotoItem( QString sourceFilePath, Collection *collection =0, QColor color =Qt::white, qreal size = 80.0);
enum Orientation { portrait, landscape };
QPixmap content();
bool hasContent();
QColor color();
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
QRectF boundingRect() const;
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
private:
qreal _size;
Orientation _orientation;
QPixmap _content;
QColor _color;
Collection *_collection;
ItemSource …Run Code Online (Sandbox Code Playgroud)