Search code examples
c++qtqfile

QFile has incomplete type


Trying to create a new QFile with

  QFile filename(file);

I keep getting the following error

error: variable has incomplete type 'SampleClass::QFile'
note: forward declaration of 'SampleClass::QFile class QFile;'

I looked it up and I have tried to fix it with #include <QFile> but I haven't managed to do that.

What am I doing wrong?


Solution

  • Your forward declaration is wrong. It should look like:

    class QFile;
    

    And it should be placed outside of any class or namespace.