error: member access into incomplete type
-
could somebody PLEASE explain to me and help me to understand the error. I can build and show the dialog object // build basic dialoog MainWindow_Bluewtoothctl_Dialog *MWBD = new MainWindow_Bluewtoothctl_Dialog(); MWBD->show(); however I cannot access its "ui" and getting the "incomplete error ". I build a local function and then have access to "ui". QT_BEGIN_NAMESPACE namespace Ui { class MainWindow_Bluewtoothctl_Dialog; } QT_END_NAMESPACE class MainWindow_Bluewtoothctl_Dialog : public QDialog { Q_OBJECT public: MainWindow_Bluewtoothctl_Dialog(QWidget *parent = nullptr); ~MainWindow_Bluewtoothctl_Dialog(); // adds BT_Utility_Library *BTUL; QString text; QString EditText(QString ); QString EditText(QString, QWidget*); QString EditText(QString, QWidget*, QWidget*); QString Command(QString ); private: public: Ui::MainWindow_Bluewtoothctl_Dialog *ui; };
MainWindow_Bluewtoothctl_Dialog::MainWindow_Bluewtoothctl_Dialog(QWidget *parent)
: QDialog(parent)
, ui(new Ui::MainWindow_Bluewtoothctl_Dialog)
{
ui->setupUi(this);
#ifdef TRACE
text = " TASK MainWindow_Bluewtoothctl_Dialog ";
text += " ";
text += Q_FUNC_INFO;
text += " @ line ";
text += QString::number(__LINE__);
//text += " TASK index ";
//text += QString::number(index);
qDebug() << text;
ui->textEdit->append(text);
#endif
text = " Constructor...";
ui->textEdit->append(" Constructor..."); // OK here
}MainWindow_Bluewtoothctl_Dialog::~MainWindow_Bluewtoothctl_Dialog()
{
delete ui;
}// build basic dialoog
MainWindow_Bluewtoothctl_Dialog *MWBD = new MainWindow_Bluewtoothctl_Dialog();
MWBD->show();// add function to bypass "INCOMPLETE WHATEVER text = " add function to bypass INCOMPLETE WHATEVER "; MWBD->EditText(text); // TEST ui MWBD->ui->textEdit->append(text);
this fails with "incomplete error " why ?
Here is full error:
mainwindow.cpp:595:17: error: member access into incomplete type 'Ui::MainWindow_Bluewtoothctl_Dialog'
MWBD->ui->textEdit->append(text);
^
/mnt/07b7c3f8-0efb-45ab-8df8-2a468771de1f/BT_NOV26_BACKUP/BT_NOV26/FT857_CAT_Bluetooth/BluetoothctldIALOG_Object/Bluetoothctl_Dialog/mainwindow_bluewtoothctl_dialog.h:16:22: note: forward declaration of 'Ui::MainWi -
could somebody PLEASE explain to me and help me to understand the error. I can build and show the dialog object // build basic dialoog MainWindow_Bluewtoothctl_Dialog *MWBD = new MainWindow_Bluewtoothctl_Dialog(); MWBD->show(); however I cannot access its "ui" and getting the "incomplete error ". I build a local function and then have access to "ui". QT_BEGIN_NAMESPACE namespace Ui { class MainWindow_Bluewtoothctl_Dialog; } QT_END_NAMESPACE class MainWindow_Bluewtoothctl_Dialog : public QDialog { Q_OBJECT public: MainWindow_Bluewtoothctl_Dialog(QWidget *parent = nullptr); ~MainWindow_Bluewtoothctl_Dialog(); // adds BT_Utility_Library *BTUL; QString text; QString EditText(QString ); QString EditText(QString, QWidget*); QString EditText(QString, QWidget*, QWidget*); QString Command(QString ); private: public: Ui::MainWindow_Bluewtoothctl_Dialog *ui; };
MainWindow_Bluewtoothctl_Dialog::MainWindow_Bluewtoothctl_Dialog(QWidget *parent)
: QDialog(parent)
, ui(new Ui::MainWindow_Bluewtoothctl_Dialog)
{
ui->setupUi(this);
#ifdef TRACE
text = " TASK MainWindow_Bluewtoothctl_Dialog ";
text += " ";
text += Q_FUNC_INFO;
text += " @ line ";
text += QString::number(__LINE__);
//text += " TASK index ";
//text += QString::number(index);
qDebug() << text;
ui->textEdit->append(text);
#endif
text = " Constructor...";
ui->textEdit->append(" Constructor..."); // OK here
}MainWindow_Bluewtoothctl_Dialog::~MainWindow_Bluewtoothctl_Dialog()
{
delete ui;
}// build basic dialoog
MainWindow_Bluewtoothctl_Dialog *MWBD = new MainWindow_Bluewtoothctl_Dialog();
MWBD->show();// add function to bypass "INCOMPLETE WHATEVER text = " add function to bypass INCOMPLETE WHATEVER "; MWBD->EditText(text); // TEST ui MWBD->ui->textEdit->append(text);
this fails with "incomplete error " why ?
Here is full error:
mainwindow.cpp:595:17: error: member access into incomplete type 'Ui::MainWindow_Bluewtoothctl_Dialog'
MWBD->ui->textEdit->append(text);
^
/mnt/07b7c3f8-0efb-45ab-8df8-2a468771de1f/BT_NOV26_BACKUP/BT_NOV26/FT857_CAT_Bluetooth/BluetoothctldIALOG_Object/Bluetoothctl_Dialog/mainwindow_bluewtoothctl_dialog.h:16:22: note: forward declaration of 'Ui::MainWiI think it's telling you that the type represented by
ui
has not been completely declared. Make sure you are #including the header files for all the types you are using.The difficult we do right away... ...the impossible takes slightly longer.
-
could somebody PLEASE explain to me and help me to understand the error. I can build and show the dialog object // build basic dialoog MainWindow_Bluewtoothctl_Dialog *MWBD = new MainWindow_Bluewtoothctl_Dialog(); MWBD->show(); however I cannot access its "ui" and getting the "incomplete error ". I build a local function and then have access to "ui". QT_BEGIN_NAMESPACE namespace Ui { class MainWindow_Bluewtoothctl_Dialog; } QT_END_NAMESPACE class MainWindow_Bluewtoothctl_Dialog : public QDialog { Q_OBJECT public: MainWindow_Bluewtoothctl_Dialog(QWidget *parent = nullptr); ~MainWindow_Bluewtoothctl_Dialog(); // adds BT_Utility_Library *BTUL; QString text; QString EditText(QString ); QString EditText(QString, QWidget*); QString EditText(QString, QWidget*, QWidget*); QString Command(QString ); private: public: Ui::MainWindow_Bluewtoothctl_Dialog *ui; };
MainWindow_Bluewtoothctl_Dialog::MainWindow_Bluewtoothctl_Dialog(QWidget *parent)
: QDialog(parent)
, ui(new Ui::MainWindow_Bluewtoothctl_Dialog)
{
ui->setupUi(this);
#ifdef TRACE
text = " TASK MainWindow_Bluewtoothctl_Dialog ";
text += " ";
text += Q_FUNC_INFO;
text += " @ line ";
text += QString::number(__LINE__);
//text += " TASK index ";
//text += QString::number(index);
qDebug() << text;
ui->textEdit->append(text);
#endif
text = " Constructor...";
ui->textEdit->append(" Constructor..."); // OK here
}MainWindow_Bluewtoothctl_Dialog::~MainWindow_Bluewtoothctl_Dialog()
{
delete ui;
}// build basic dialoog
MainWindow_Bluewtoothctl_Dialog *MWBD = new MainWindow_Bluewtoothctl_Dialog();
MWBD->show();// add function to bypass "INCOMPLETE WHATEVER text = " add function to bypass INCOMPLETE WHATEVER "; MWBD->EditText(text); // TEST ui MWBD->ui->textEdit->append(text);
this fails with "incomplete error " why ?
Here is full error:
mainwindow.cpp:595:17: error: member access into incomplete type 'Ui::MainWindow_Bluewtoothctl_Dialog'
MWBD->ui->textEdit->append(text);
^
/mnt/07b7c3f8-0efb-45ab-8df8-2a468771de1f/BT_NOV26_BACKUP/BT_NOV26/FT857_CAT_Bluetooth/BluetoothctldIALOG_Object/Bluetoothctl_Dialog/mainwindow_bluewtoothctl_dialog.h:16:22: note: forward declaration of 'Ui::MainWiYou need to work on your google foo -- this was the first result when I searched on "access into incomplete type" and it has a very good explanation of the problem https://stackoverflow.com/questions/19962812/error-member-access-into-incomplete-type-forward-declaration-of[^]
Be wary of strong drink. It can make you shoot at tax collectors - and miss. Lazarus Long, "Time Enough For Love" by Robert A. Heinlein
-
I think it's telling you that the type represented by
ui
has not been completely declared. Make sure you are #including the header files for all the types you are using.The difficult we do right away... ...the impossible takes slightly longer.
-
Many thanks, my own fault...missed ui header. I always forget to add the "ui...." header created by QT... The "forward note" error was not too helpful either. #include "ui_mainwindow_bluewtoothctl_dialog.h"
Glad I was able to help!
The difficult we do right away... ...the impossible takes slightly longer.