3

私のコードにはMcdGraphicsScene、から継承するクラスがありますが、のインスタンスへQGraphicsSceneのポインタを渡そうとすると、次のエラーが発生します。McdGraphicsSceneQGraphicsView::setScene(QGraphicsScene* scene);

../MeriseModeler/merisemodeler/mcdui.cpp: In member function 'void McdUi::setModel(McdModel*)':
../MeriseModeler/merisemodeler/mcdui.cpp:34:42: error: no matching function for call to 'QGraphicsView::setScene(McdGraphicsScene*)'
../MeriseModeler/merisemodeler/mcdui.cpp:34:42: note: candidate is:
In file included from ../../.qt5/5.0.0/gcc/include/QtWidgets/QGraphicsView:1:0,
                 from ../MeriseModeler/merisemodeler/mcdui.cpp:10:
../../.qt5/5.0.0/gcc/include/QtWidgets/qgraphicsview.h:161:10: note: void QGraphicsView::setScene(QGraphicsScene*)
../../.qt5/5.0.0/gcc/include/QtWidgets/qgraphicsview.h:161:10: note:   no known conversion for argument 1 from 'McdGraphicsScene*' to 'QGraphicsScene*'

これがクラスのコードです

class McdGraphicsScene : public QGraphicsScene
{
    Q_OBJECT

    // Methods and attributs
};
4

1 に答える 1

8

の前方宣言を使用していますMcdGraphicsSceneか?

実際のクラス定義が呼び出しサイトに表示されていることを確認してください。利用可能な前方宣言しかない場合、呼び出し元のコードはMcdGraphicsSceneから継承するものを推測できませんQGraphicsScene

于 2013-03-06T12:35:31.653 に答える