Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Invalid use of incomplete type; forward declaration of struct.....from auto-generated code
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.8k Views
  • 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 Offline
    T Offline
    tesmai4
    wrote on last edited by
    #1

    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
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      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
      0
      • T Offline
        T Offline
        tesmai4
        wrote on last edited by
        #3

        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
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          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
          0
          • T Offline
            T Offline
            tesmai4
            wrote on last edited by
            #5

            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
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved