【问题标题】:Can't cast qgraphicsitem无法投射 qgraphicsitem
【发布时间】:2012-04-29 01:45:06
【问题描述】:

好的,我认为错误可能很明显,但目前我找不到。

我有:

class GraphViewCustom : public QGraphicsView
{
...
protected:
  void wheelEvent(QWheelEvent *event);
}

和类似的类 GraphSceneCustom(从 QGraphicsScene 派生)和 GraphPixmapItemCustom(从 QGraphicsPixmapItem)。在上面的 wheelEvent() 中,我有这样一行:

qgraphicsitem_cast(items().first());

为了便于阅读和减少复杂性,我删除了替换的左侧。在这一行我得到了

没有匹配函数调用'qgraphicsitem_cast(QGraphicsItem*&)'

我做错了什么?我想这个错误很明显(我最常见的错误是什么——我很少犯难的。但是当我这样做时,它们真的很难)。

是的,我已经添加了 QGraphicsItem 类的标题。

【问题讨论】:

  • 没关系,这是一个明显的错误。没有 子句。因此,使用 qgraphicsItem_cast(items().first()) 就可以了。我仍然无法回答我自己的问题,所以我在这里写。为什么我发布后答案就来了:(
  • 哦,当然。别难过,我也错过了。

标签: qt casting qgraphicsview qgraphicsitem


【解决方案1】:

qgraphicsitem_cast 在#include <QGraphicsItem> 中定义。您是否将其包含在相关文件中?

【讨论】:

  • 我已经在对这个问题的评论中回答了自己。我知道这很简单:(
猜你喜欢
  • 2017-03-17
  • 2014-06-04
  • 2012-08-23
  • 2013-10-04
  • 1970-01-01
  • 2020-10-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多