lennin92
lennin92

Reputation: 513

invalid use of incomplete type/ foward declaration of

I've been looking for info about this problem .. but none of the solutions I've found have helped me, I really hope that you can helpme

the compiler errors are:

    [...]\maintabholder.cpp: In constructor 'MainTabHolder::MainTabHolder(QWidget*)':
    [...]\maintabholder.cpp:6:16: error: invalid use of incomplete type 'class Ui::MainTabHolder'
    In file included from [...]\maintabholder.cpp:1:0:
    [...]\maintabholder.h:7:7: error: forward declaration of 'class Ui::MainTabHolder'
    [...]\maintabholder.cpp:8:7: error: invalid use of incomplete type 'class Ui::MainTabHolder'
    In file included from [...]\maintabholder.cpp:1:0:
    [...]\maintabholder.h:7:7: error: forward declaration of 'class Ui::MainTabHolder'
    [...]\maintabholder.cpp: In destructor 'virtual MainTabHolder::~MainTabHolder()':
    [...]\maintabholder.cpp:13:12: warning: possible problem detected in invocation of delete operator: [enabled by default]
    [...]\maintabholder.cpp:13:12: warning: invalid use of incomplete type 'class Ui::MainTabHolder' [enabled by default]
    In file included from [...]\maintabholder.cpp:1:0:
    [...]\maintabholder.h:7:7: warning: forward declaration of 'class Ui::MainTabHolder' [enabled by default]
    [...]\maintabholder.cpp:13:12: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined

Can you give a help with this? I would appreciate it...

Upvotes: 0

Views: 5056

Answers (2)

NanLv
NanLv

Reputation: 9

You included the ui define head in your .cpp file, and defined a private member "Ui::MainTabHolder *ui;" in your .h file, so you need to add a forward declaration in your .h file(maintabholder.h:) before your class defination:

class Ui_MainTabHolder;

here Ui_MainTabHolder is your Ui class name, check your own project for correct one.

Upvotes: 0

Synxis
Synxis

Reputation: 9388

You are using a file generated by uic from Qt; you should verify that this tool successfully generate the file, by for example checking the build output and the file itself. Also, check that it is in the *.pro file (ie, that maintabholder.h is marked to be processed by uic).

I personnally advise to use the multiple inheritance method for ui :

// in maintabholder.h
// ...
#include "ui_maintabholder.h"

class MainTabHolder : public QMainWindow, public Ui::MainTabHolder
{
    // ...
};

Simpler to use, and if you have a problem with the ui_*.h file the error is more explicit.

You should post ui_maintabholder.h.

Upvotes: 3

Related Questions