‘SceneElement’ was not declared in this scope

873 views Asked by At

I want to use selection in my 3d viewer ,and I tried this example ,but I faced the following problem :

error: ‘SceneElement’ was not declared in this scope QList sceneElements ;

scene.h file:

#ifndef SCENE_H
#define SCENE_H
 #include <sceneelement.h>
#include <QGLViewer/qglviewer.h>

class Scene
{

private:
    /// The list of elements that make up the scene

 QList <SceneElement*> sceneElements ;

public:
     Scene();
    /// Creates a scene with RenderElements positionned on a regular grid.
    /// Consider increasing selectBufferSize() if you use more RenderElements.

    void draw();
    void setSelected(int i);
    void drawWithNames();
void clearSelection();
};

sceneelement.h file:

#include <QGLViewer/qglviewer.h>
#include <viewer.h>

class SceneElement
{

    friend class Scene;
private:

    qglviewer::Frame frame;
    bool isSelected;


public:
    /// Constructor
    SceneElement(float x, float y){
        isSelected=false;
        qglviewer::Vec pos(x,y,0.0);
        frame.setPosition(pos);
    }
    /// Draws this element
    void draw() const;

};

I don't know why it couldn't use SceneElement,although I included sceneelement.h

I appreciate any help , thank you.

1

There are 1 answers

0
user3019180 On

that suggestion solves my problem It looks like you have a circular dependency. Try to add a forward declaration class SceneElement just before the line class Scene in scene.h – Romha Korev