compiler reports that Ui is an incomplete type
-
Class is defined/constructed as follows:
namespace Ui { class WifiSetup; } class WifiSetup : public QDialog { Q_OBJECT private: Ui::WifiSetup *ui; ... WifiSetup::WifiSetup(QString serialNbr, DeviceModel *d, QModelIndex *qmi, Worker *pWorker, QWidget *parent) : QDialog(parent), ui(new Ui::WifiSetup),
and I'm getting the error message:
error: allocation of incomplete type 'Ui::WifiSetup'
What did I do wrong? Thanks...
-
@mzimmers said in compiler reports that Ui is an incomplete type:
namespace Ui {
class WifiSetup;
}Is this intended to be fleshed out later? class WifiSetup; is a class prototype. Is it defined somewhere else?
If you want this to define a class you can do this I think:class WifiSetup { };
-
@aha_1980 I don't understand -- my class definition is in the header file, and the header file is included in the source file. (I didn't bother including this in my original post, as I thought it was the implicit method of creating classes.)
wifisetup.h:
namespace Ui { class WifiSetup; } class WifiSetup : public QDialog { Q_OBJECT private: Ui::WifiSetup *ui; ...
wifisetup.cpp:
#include "wifisetup.h" #include "ui_wifisetup.h" #include "worker.h" WifiSetup::WifiSetup(QString serialNbr, DeviceModel *d, QModelIndex *qmi, Worker *pWorker, QWidget *parent) : QDialog(parent), ui(new Ui::WifiSetup), ...
I'd expect the definition (from the header file) to be visible here, so I guess I don't understand how this really works.
-
@aha_1980 I'm doing (what appears to be) the same thing in another class, and that compiles fine.
namespace Ui { class EditDialog; } class EditDialog : public QDialog { Q_OBJECT public: explicit EditDialog(DeviceModel *d, QModelIndex *qmi, Worker *pWorker, QWidget *parent = nullptr); private: Ui::EditDialog *ui; ... } EditDialog::EditDialog(DeviceModel *d, QModelIndex *qmi, Worker *pWorker, QWidget *parent) : QDialog(parent), ui(new Ui::EditDialog), ...
I'm sure I'm overlooking something obvious, but they look the same to me.
-
-
@mzimmers said in compiler reports that Ui is an incomplete type:
I know it's some brain-dead mistake I've introduced somewhere, but I sure can't find it.
@aha_1980 said it. You have, I'm betting, something called
wifisetup.ui
in your project. If you don't then that's a problem. Then you should have#include "ui_wifisetup.h"
in your cpp file. If you don't then that's a problem. Note thatUi::WifiSetup
is different fromWifiSetup
, the former's namespaced for good reason. -
@kshegunov yes on both counts: I have a wifisetup.ui file in the project, and I include "ui_wifisetup.h" in my wifisetup.cpp file. It should be functionally identical to my editdialog class, which compiles just fine. Wifisetup used to compile, too. But I introduced a change somewhere that I can't find and it's causing this issue.
-
error: allocation of incomplete type 'Ui::WifiSetup'
This means the class declaration is not available. Troubleshoot as follows (skip steps that you've checked already):
- Make sure you include the generated header where you allocate.
- Make sure qmake's rerun
- Make sure the name of the widget in the designer matches the name of the class.
-
@mzimmers said in compiler reports that Ui is an incomplete type:
I introduced a change somewhere
I think that in order for this to be an issue then that change would have been somewhere in the .h file. Is there anything in the .h that defines the prototype that does anything more than define a pointer than this: Ui::EditDialog *ui; I am thinking of functions defined as inline vs functions defined in a cpp file.
or
Something is interfering with the compilation of cpp files associated with that object. Did a cpp file get excluded from the pro file? By accident or design?
-
@kshegunov said in compiler reports that Ui is an incomplete type:
error: allocation of incomplete type 'Ui::WifiSetup'
This means the class declaration is not available. Troubleshoot as follows (skip steps that you've checked already):
- Make sure you include the generated header where you allocate.
- Make sure qmake's rerun
- Make sure the name of the widget in the designer matches the name of the class.
Ding. It was #3, a result of my hasty editing in Designer. Thanks to all who looked at this.
-
This post is deleted!