Invalid use of incomplete type

I get these errors i dont have any idea how to solve.
I have searched Goolge and StackOverflow and found stuff related to this but i couldn't solve this.

Any help is much appreciated.


error: invalid use of incomplete type 'class Ui::AddDialog'
error: forward declaration of 'class Ui::AddDialog'


addDialog.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef ADDDIALOG_H
#define ADDDIALOG_H

#include <QDialog>

namespace Ui {
class AddDialog;
}

class AddDialog : public QDialog
{
    Q_OBJECT

public:
    explicit AddDialog(QWidget *parent = 0);
    ~AddDialog();

private:
    Ui::AddDialog *ui;
};

#endif // ADDDIALOG_H 


AddDialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "addDialog.h"
#include "ui_addDialog.h"

AddDialog::AddDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::AddDialog)
{
    ui->setupUi(this);
}

AddDialog::~AddDialog()
{
    delete ui;
}


gpa.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef GPA_H
#define GPA_H


#include <QMainWindow>

namespace Ui {
class Gpa;
}

class Gpa : public QMainWindow
{
    Q_OBJECT
    
public:
    explicit Gpa(QWidget *parent = 0);
    ~Gpa();
    
private slots:
    void on_pushButton_3_clicked();

private:
    Ui::Gpa *ui;
};

#endif // GPA_H 


gpa.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "gpa.h"
#include "ui_gpa.h"


Gpa::Gpa(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Gpa)
{
    ui->setupUi(this);
}

Gpa::~Gpa()
{
    delete ui;
}

How does "ui_addDialog.h" look like?
its a form. Im programming with Qt

Why are the errors only for AddDialog when AddDialog has the same structure as Gpa
Last edited on
ui_AddDialog is generated by Qt Creator.
Make sure you made AddDialog with Qt Creator.
Also try doing a clean build.
I have done the clean build but no change.

Yes i made AddDialog with QtCreator.
I then added the header and .cpp files manually instead of them being generated automatically as it was with Gpa.

But I think Gpa files were automatically generated becauase Gpa is my main project.
I fixed the issue.

I selected Designer form file instead of Designer form class when creating the AddDialog form.
Topic archived. No new replies allowed.