Qt Creator: “XYZ does not name a type”


Question

This is a very frustrating error message in Qt Creator: ’XYZ’ does not name a type. This usually means that there is an error in the class XYZ that prevents the compiler from generating the type, but there are no additional hints as to what went wrong.

Any suggestions?

1
8
9/14/2009 1:48:41 PM

Accepted Answer

I found this problem on qtcreator 3.4.1 and QT 5.4, when I replace such as

#include <QTextEdit>

with

class QTextEdit;

this problem gone.

2
6/15/2015 12:13:42 AM

i just had this problem, and like Arckaroph have said : the problem is that when we include a header file in a source code file, and we use in it the directive #ifndef, we can't include it again in a header file to give a type of it's included class to a variable in source code file

example :

class1.h contains Class1 class2.h contains Class2 class2 have a private variable V with class1 type if we include class1.h in class2.CPP we can't include it in class2.h to give V a class1 type.

so we put in class2.cpp class2.h before class1.h or we delete class1.h from class2.cpp


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon