invalid use of incomplete type / forward decalration of 'class UI::file_ui'
-
I have two files:
module.h
#ifndef MODULE_H #define MODULE_H #include "parent_module.h" class parent_module; class module : public parent_module { public: module(); ... private: ... }; #endif // MODULE_H
and module_ui.h
#ifndef MODULE_UI_H #define MODULE_UI_H #include ... #include "../module.h" namespace Ui { class module_ui; } class module; class module_ui : public QDialog, module { Q_OBJECT public: ... private: ... }; #endif // MODULE_UI_H
And this is the implementation for the ui header file: module_ui.cpp
#include "module_ui.h" #include "ui_module_ui.h" module_ui::module_ui(QWidget *parent) : QDialog(parent), ui(new Ui::module_ui) //error occurs here { ui->setupUi(this); //and here ... } module_ui::~module_ui() { qDebug() << "Module_UI destructor called"; ... delete ui; //and here (and basically everywhere ui is called) }
Basically a parent/base class that is inheritted by child ui class. I have this same structure for many other files and it works fine. However when I added this set I keep getting the following errors:
..module_ui.cpp:28:16: error: invalid use of incomplete type 'class Ui::module_ui'
ui(new Ui::module_ui)
^~~~~~~~~~~~~~~~~~~In file included from ..\module_ui.cpp:22:0:
..\module_ui.h:23:7: note: forward declaration of 'class Ui::module_ui'
class module_ui;
^~~~~~~~~~~~~~~~~~~I have the all the files properly add in the .pro file (.cpp to SOURCES, .h to HEADERS, and .ui to FORMS)
I literally went back and followed the exact same structure as all the other files which are working fine. I've got no idea what I am missing here.Help is appreciated.
-
Hi,
Did you check that uic is properly run on that form ?
-
@SGaist said in invalid use of incomplete type / forward decalration of 'class UI::file_ui':
check
I just checked and it is not.. The ui_module_ui.h file generated has instances of module.h instead of module_ui.h.
class Ui_module //here it should be UI_module_ui { public: ... void setupUi(QDialog *module) //and here it should pass a pointer to module_ui { ... //all other instances are the same }
I can fix it manually but that would not solve the problem for anyone building from scratch. Any idea why that is happening? I believe I have the include statements the right way round
-
I currently wonder if you using _ui in your designer based widget does not trigger some issue.
Try renaming it to something more meaningful without using _ui.
-
Then with silly ideas: did you check whether you have a missing backslash in your .pro when listing that particular form ? If you do it one file per line that is.
-
Did you already nuke the build folder and rebuild from scratch ?
-
@SGaist I finally figured it out.
The module.h file was actually the ui file at first and then I created a child class module_ui.h that inherits from it and instantiates the actual QDialog. Soo, I changed everything up but forgot to change the class name in the .ui file.. Pretty silly
Anyways thanks for your help.
-
@Adham said in invalid use of incomplete type / forward decalration of 'class UI::file_ui':
Pretty silly
So we were right ! :-D