I am getting the error "field ui1 has incomplete type". I am a beginner . Please help.



  • File name dialog.h
    @#ifndef LISTDIALOG_H
    #define LISTDIALOG_H

    #include <QDialog>

    namespace Ui {
    class ListDialog;
    class EditDialog;
    }
    class ListDialog : public QDialog
    {
    Q_OBJECT

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

    public slots:
    void addItem();
    void editItem();
    void deleteItem();

    private:
    Ui::ListDialog *ui;
    };
    class EditDialog:public QDialog
    {
    public:
    EditDialog(QWidget *parent=0);
    const QString name() const;
    void setName(const QString&);
    private:
    Ui::EditDialog ui1;

    };

    #endif // LISTDIALOG_H@

    The dialog.cpp file is

    @#include "dialog.h"
    #include "ui_dialog.h"
    #include "ui_editdialog.h"
    ListDialog::ListDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ListDialog)
    {
    ui->setupUi(this);
    }

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

    EditDialog::EditDialog(QWidget *parent):QDialog(parent)
    {

    ui1.setupUi(this);
    

    }

    void ListDialog::addItem()
    {
    //EditDialog dlg(this);
    //dlg.exec();
    }
    void ListDialog::editItem(){}
    void ListDialog::deleteItem(){}@



  • Hi!

    It seems you are mixing two forms in one, and the UIC compiler gets lost somewhere. If I'm not wrong, in your project you only have one form .ui, whose name is ListDialog. Look inside ui_dialog.h and you may find something like

    @namespace Ui {
    class ListDialog: public Ui_Dialog {};
    } // namespace Ui

    QT_END_NAMESPACE@

    So when pressing CTRL and clicking over your ListDialog in

    @namespace Ui {
    class ListDialog; //click this one
    class EditDialog;
    }@

    Qt must jump to that part of the code. If you repeat this operation with your EditDialog, Qt will remain in the same file. That means there is no .ui file for your EditDialog. This should be the reason why you get that message. So, go on, create a new form and be sure to specify its name correctly. Then include the autogenerated header ui_whateverNameYouUsed.h it in your .cpp and re-compile.

    If you have any doubts, just ask. Good luck!



  • What I see:

    You instantiate an object of a class in it's own declaration.
    I may be wrong, but I can imagine this couldn't work...

    Greetings
    Joerg



  • No I have two user interfaces editdialog.ui and listdialog.ui



  • [quote author="QMartin" date="1360692450"]Hi!

    It seems you are mixing two forms in one, and the UIC compiler gets lost somewhere. If I'm not wrong, in your project you only have one form .ui, whose name is ListDialog. Look inside ui_dialog.h and you may find something like

    @namespace Ui {
    class ListDialog: public Ui_Dialog {};
    } // namespace Ui

    QT_END_NAMESPACE@

    So when pressing CTRL and clicking over your ListDialog in

    @namespace Ui {
    class ListDialog; //click this one
    class EditDialog;
    }@

    Qt must jump to that part of the code. If you repeat this operation with your EditDialog, Qt will remain in the same file. That means there is no .ui file for your EditDialog. This should be the reason why you get that message. So, go on, create a new form and be sure to specify its name correctly. Then include the autogenerated header ui_whateverNameYouUsed.h it in your .cpp and re-compile.

    If you have any doubts, just ask. Good luck![/quote]

    I have created two interfaces editdialog.ui and listdialog.ui





  • Thanks your suggestion solved my problem.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.