If you use a (any) Qt-class, in a header you usually need to include its header.
Exceptions are:
* if you only use a pointer or reference or return type, a forward declaration is enough.
class X
{
QTreeView *tv;
// forward decl "class QTreeView;" is enough QHash<QString,QList<int> > hash; // needs includes for QString, QList and QHash
QString getName
() const;
// forward declaration enough };
class X
{
QString s; // needs include
QTreeView *tv; // forward decl "class QTreeView;" is enough
QHash<QString,QList<int> > hash; // needs includes for QString, QList and QHash
QString getName() const; // forward declaration enough
};
To copy to clipboard, switch view to plain text mode
Sometimes you get away without including a header, namely if you include other headers that in turn include the header you would need.
Still, I consider it good practice to explicitly include any header of a class that is explicitly used in a class.
In your case: QStringList inherits QList. Therefore its header must include the QList-header. Thus you do not have to include it.
QString is part of QStringList as well.
HTH
Bookmarks