First of all, I am confused by the fact that there are two very similar ads next to each other, one with an error without the other.

ошибка: 'ContactFaceElement' was not declared in this scope QList<ContactFaceElement *> face; ^~~~~~~~~~~~~~~~~~ ошибка: template argument 1 is invalid QList<ContactFaceElement *> face; ^ #ifndef ORGANISATIONELEMENT_H #define ORGANISATIONELEMENT_H #include <QObject> #include <elementDB/contactfaceelement.h> #include <elementDB/geoelement.h> #include <QStringList> class OrganisationElement : public QObject { Q_OBJECT public: explicit OrganisationElement(QObject *parent = 0); class element { QString name; QList<ContactFaceElement *> face; // ОШИБКА ЗДЕСЬ QList<GeoElement *> geo; QStringList sites; QStringList phone; }; bool findOrganisation(OrganisationElement::element); bool findOrganisationFromEmail(QString); QList<OrganisationElement::element*> elements; signals: public slots: }; #endif // ORGANISATIONELEMENT_H 

! two classes

 #ifndef CONTACTFACEELEMENT_H #define CONTACTFACEELEMENT_H #include <QObject> #include <elementDB/geoelement.h> #include <QDate> #include <QStringList> #include <elementDB/organisationelement.h> class ContactFaceElement : public QObject { Q_OBJECT public: explicit ContactFaceElement(QObject *parent = 0); class element { QString name; QString last_name; QString patronymic; QDate birthday; GeoElement * geo; QStringList phone; }; bool findContactFace(ContactFaceElement::element); bool findContactFaceFromEmail(QString); QList<ContactFaceElement::element *> face; QList <int> id_contact_face; void readListIdContactFace_FromOrganisation(OrganisationElement*); signals: public slots: private: void readListIdContactFace_Email(QString); void addIdContactFace(int); }; #endif // CONTACTFACEELEMENT_H #ifndef GEOELEMENT_H #define GEOELEMENT_H #include <QObject> #include <QStringList> class GeoElement : public QObject { Q_OBJECT public: explicit GeoElement(QObject *parent = 0); class g { public: QString city; QString country; QString region; QString state; int zip_code; QString street; int home; QString home_word; int box; int box_word; QString currency_code; QString currency; int id_countries; int id_cities; bool biggest_city; int id_rayon; QString rayon; }; bool findGeo(GeoElement::g); bool findGeoFromEmail(QString); QList<GeoElement::g*> geos; QList<int> id_geo; signals: public slots: private: int idGeoInfoEmail(int); int idGeoList(int); void addGeosFromId(int); }; #endif // GEOELEMENT_H 
  • one
    why you have #include <elementDB/contactfaceelement.h> and not #include "elementDB/contactfaceelement.h" ? - Sublihim
  • for uniformity of code, this connection method works too - shaman888
  • in what order are the header files in the .pro file (HEADERS) connected? - Sublihim
  • elementDB / geoelement.h \ elementDB / contactfaceelement.h \ - shaman888
  • and if you do so? elementDB/organisationelement.h \ elementDB/geoelement.h \ elementDB/contactfaceelement.h \ - Sublihim

1 answer 1

The error occurs due to the fact that somewhere contactfaceelement.h used earlier than organisationelement.h . Because of this, the compiler does not find the class declaration ContactFaceElement

Use predeclaration in organizingelement.h

 #ifndef ORGANISATIONELEMENT_H #define ORGANISATIONELEMENT_H #include <QObject> #include <elementDB/contactfaceelement.h> #include <elementDB/geoelement.h> #include <QStringList> // Добавьте предварительное объявление класса class ContactFaceElement; class OrganisationElement : public QObject { Q_OBJECT // Дальше ваш код }; 

But you need to understand the order of using includ-s in other headers