Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Invalid use of incomplete type; forward declaration of struct.....from auto-generated code

    General and Desktop
    2
    5
    2583
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      tesmai4 last edited by

      Dear all,

      I created a "QWizardPage form class" in my project. I get the following errors from the auto-generated code:

      registerwizardpage.cpp: In constructor 'RegisterWizardPage::RegisterWizardPage(QWidget*)':
      registerwizardpage.cpp:6: error: invalid use of incomplete type 'struct Ui::RegisterWizardPage'
      registerwizardpage.h:7: error: forward declaration of 'struct Ui::RegisterWizardPage'
      registerwizardpage.cpp:8: error: invalid use of incomplete type 'struct Ui:RegisterWizardPage'
      registerwizardpage.h:7: error: forward declaration of 'struct Ui::RegisterWizardPage'
      registerwizardpage.cpp: In destructor 'virtual RegisterWizardPage::~RegisterWizardPage()':
      registerwizardpage.cpp:13: warning: possible problem detected in invocation of delete operator:
      registerwizardpage.cpp:13: warning: invalid use of incomplete type 'struct Ui::RegisterWizardPage'
      registerwizardpage.h:7: warning: forward declaration of 'struct Ui::RegisterWizardPage'

      Any help for resolving this error please.

      RegisterWizardPage.h

      @#ifndef REGISTERWIZARDPAGE_H
      #define REGISTERWIZARDPAGE_H

      #include <QWizardPage>

      namespace Ui {
      class RegisterWizardPage;
      }

      class RegisterWizardPage : public QWizardPage
      {
      Q_OBJECT

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

      private:
      Ui::RegisterWizardPage *ui;
      };

      #endif // REGISTERWIZARDPAGE_H
      @

      RegisterWizardPage.cpp

      @#include "registerwizardpage.h"
      #include "ui_registerwizardpage.h"

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

      RegisterWizardPage::~RegisterWizardPage()
      {
      delete ui;
      }
      @

      1 Reply Last reply Reply Quote 0
      • dheerendra
        dheerendra Qt Champions 2022 last edited by

        Hope you did not change the objectName of Wizard in Designer.

        In order to check this, can you create new project for the same type of wizard and don't change any parameters/properties in designer form.
        Now compile and run. See if you observe the same errors.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply Reply Quote 0
        • T
          tesmai4 last edited by

          Thanks for your reply.

          I did change the objectName of QWizard instance in QT Designer. I did not change any parameters.
          I did clean my project and executed QMake before build all.
          How can I correct/avoid this error?

          Why and how is it important to not the change name of QWizard in designer?

          1 Reply Last reply Reply Quote 0
          • dheerendra
            dheerendra Qt Champions 2022 last edited by

            Following code snippet depends on objectName

            @namespace Ui {
            class WizardPage;
            }

            and

            private:
            Ui::WizardPage *ui;
            @

            Dheerendra
            @Community Service
            Certified Qt Specialist
            http://www.pthinks.com

            1 Reply Last reply Reply Quote 0
            • T
              tesmai4 last edited by

              Thanks for your reply. Problem solved.

              Could you please have a look at this "issue":https://qt-project.org/forums/viewthread/45125/

              Regards,

              1 Reply Last reply Reply Quote 0
              • First post
                Last post