Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, June 2007
use of undefined type


Message 1 in thread

Hello

In a QGraphicsFramework apllication, qgraphicsitem has been subclassed in
order to create a custom graphical item.
The above error mentioned on the Subject use of undefined type
has occured during the building process.

The FetaureItem Object is a subclass of qgraphicsitem and FeatureType is
an enumeration of feature type graphical items (QGraphicsItem) . The error
below is related with a function
used in the QGraphicsScene class which is declared like this:

void setFeatureType(FeatureItem::FeatureType type);

and the enumration used belongs to the FaetureItem class :

enum FeatureType { Point, Line, Rectangle, Circle, Polygon, Polyline };


1>c:\apps\justacad-2\graphScene.h(103) : error C2027: use of undefined type
'FeatureItem'
1>        c:\apps\justacad-2\graphScene.h(48) : see declaration of
'FeatureItem'
1>c:\apps\justacad-2\graphScene.h(103) : error C2061: syntax error :
identifier 'FeatureType'
1>c:\apps\justacad-2\graphScene.h(173) : error C2027: use of undefined type
'FeatureItem'
1>        c:\apps\justacad-2\graphScene.h(48) : see declaration of
'FeatureItem'
1>c:\apps\justacad-2\graphScene.h(173) : error C2146: syntax error : missing
';' before identifier 'myFeatureType'
1>c:\apps\justacad-2\graphScene.h(173) : error C4430: missing type specifier
- int assumed. Note: C++ does not support default-int
1>c:\apps\justacad-2\graphScene.h(173) : error C4430: missing type specifier
- int assumed. Note: C++ does not support default-int

Any ideas on what is wrong with the code? Thank you in advance.

-- 
 [ signature omitted ] 

Message 2 in thread

On 18.06.07 16:52:49, Nikos Geronitidis wrote:
> 1>c:\apps\justacad-2\graphScene.h(103) : error C2027: use of undefined type
> 'FeatureItem'
> 1>        c:\apps\justacad-2\graphScene.h(48) : see declaration of
> 'FeatureItem'
> 1>c:\apps\justacad-2\graphScene.h(103) : error C2061: syntax error :
> identifier 'FeatureType'
> 1>c:\apps\justacad-2\graphScene.h(173) : error C2027: use of undefined type
> 'FeatureItem'
> 1>        c:\apps\justacad-2\graphScene.h(48) : see declaration of
> 'FeatureItem'
> 1>c:\apps\justacad-2\graphScene.h(173) : error C2146: syntax error : missing
> ';' before identifier 'myFeatureType'
> 1>c:\apps\justacad-2\graphScene.h(173) : error C4430: missing type specifier
> - int assumed. Note: C++ does not support default-int
> 1>c:\apps\justacad-2\graphScene.h(173) : error C4430: missing type specifier
> - int assumed. Note: C++ does not support default-int
> 
> Any ideas on what is wrong with the code? Thank you in advance.

Which code? You didn't show any code. I guess graphScene.h doesn't
#include the header which contains the FeatureItem declaration.

Andreas

-- 
 [ signature omitted ] 

Message 3 in thread

I appologize for the incomplete information, i have included the header
related to the FeatureItem (featureitem.h).
Here is a part from the code..

The QGraphicsItem :

#ifndef FEATUREITEM_H
#define FEATUREITEM_H

#include <QGraphicsItem>
.
.

class FeatureItem : public QGraphicsItem
{
public:
    enum FeatureType { Point, Line, Rectangle, Circle, Polygon, Polyline };
FeatureItem(FeatureType featureType, QVector<QPointF> pointsRoot,
QGraphicsItem *parent = 0, QGraphicsScene *scene = 0);
.
.
.
#endif



And this is a part from the QGraphicsScene:

#ifndef GraphScene_H
#define GraphScene_H

#include <QGraphicsScene>
#include <QGraphicsItem>
.
.#include "featureitem.h"

class FeatureItem;
class QGraphicsItem;
.
.
class GraphScene : public QGraphicsScene
{
    Q_OBJECT

public:
     enum Mode { InsertPoint, InsertLine, InsertRect, InsertCircle,
InsertPolyline, InsertPolygon, InsertText, MoveItem };
     GraphScene(QObject * parent = 0);
     .
     .
      public slots:
              void setMode(Mode mode);
              void setFeatureType(FeatureItem::FeatureType type);
              .
              .
private:
      .
      .
      Mode myMode;
      FeatureItem::FeatureType myFeatureType;
      .
      .
#endif



And a part from the implementation of GraphScene:

GraphScene::GraphScene(QObject *parent)
: QGraphicsScene(parent)
{
    setItemIndexMethod(QGraphicsScene::NoIndex);
    setSceneRect(0, 0, 99999.99, 99999.99);
    myFeatureType = FeatureItem::Point;
    myMode = MoveItem;
}
void GraphScene::setMode(Mode mode)
{
    myMode = mode;
}

void GraphScene::setFeatureType(FeatureItem::FeatureType type)
{
    myFeatureType = type;
}


-- 
 [ signature omitted ] 

Message 4 in thread

> #include <QGraphicsItem>
> #include "featureitem.h"
> 
> class FeatureItem;
> class QGraphicsItem;

Seems like you're overwriting the definition of FeatureItem and 
QGraphicsItem with forward declarations in the next lines. This won't 
work; get rid of the forward declarations.

Martin

-- 
 [ signature omitted ]