Hi guys, I got a little Problem with a forward declaration. It may be solved easily, but I don't find my mistake.
I got a class TrackElement that has exactly the following header file.
#ifndef TRACKELEMENT_H
#define TRACKELEMENT_H
#include <QLabel>
#include "tracktest.h"
class TrackTest;
class TrackElement
: public QLabel{
Q_OBJECT
public:
explicit TrackElement(TrackTest *parent = 0);
private:
TrackTest test;
};
#endif // TRACKELEMENT_H
#ifndef TRACKELEMENT_H
#define TRACKELEMENT_H
#include <QLabel>
#include "tracktest.h"
class TrackTest;
class TrackElement : public QLabel
{
Q_OBJECT
public:
explicit TrackElement(TrackTest *parent = 0);
private:
TrackTest test;
};
#endif // TRACKELEMENT_H
To copy to clipboard, switch view to plain text mode
First, when I didn't use the forward declaration, the constructor had problems with it too, because im using the TrackElement to create TrackTest and vice versa.
With the forward declaration the constructor causes no errors, but my private test variable of type TrackTest does. "field 'test' has incomplete type"
I don't get it why, if I create a new TrackTest file in the TrackElement .cpp-file, there is no error at all.
Thanks for fast answers
Bookmarks