QT Creator - CLASSNAME没有命名类型"后退按钮"履行

时间:2018-02-10 10:29:07

标签: c++ qt

所以我对QT真的很陌生,而我面临的这个问题根本无法理解。我有一个程序,每个页面上都有一个下一个按钮,一些上面有一个后退按钮。我已经实现的所有下一个按钮工作得很好,但是后退按钮不是,即使我实现它的方式与我在网上看到的其他按钮相同。

这是第三页的头文件,其中包含后退按钮:

//ThirdPage header file
#ifndef THIRDPAGE_H
#define THIRDPAGE_H

#include <QDialog>
#include "secondpage.h"

namespace Ui {
class ThirdPage;
}

class ThirdPage : public QDialog
{
    Q_OBJECT

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

private slots:
    void on_backButton_clicked();

private:
    Ui::ThirdPage *ui;
    SecondPage *secPage;
};

#endif // THIRDPAGE_H

这是第三页的cpp文件:

//third page cpp file
#include "thirdpage.h"
#include "ui_thirdpage.h"
#include "secondpage.h"

ThirdPage::ThirdPage(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ThirdPage)
{
    ui->setupUi(this);
    //setFixedSize(854,480);
    setMinimumSize(854,480);
}

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

void ThirdPage::on_backButton_clicked()
{
    hide();
    secPage = new SecondPage(this);
    secPage->show();

}

这些是第二页的标题和cpp文件,应该在按下后退按钮时打开

//Second Page header file
#ifndef SECONDPAGE_H
#define SECONDPAGE_H

#include <QDialog>
#include "thirdpage.h"

namespace Ui {
class SecondPage;
}

class SecondPage : public QDialog
{
    Q_OBJECT

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

private slots:
    void on_pushButton_clicked();

private:
    Ui::SecondPage *ui;
    ThirdPage *thirdPage;
};
#endif // SECONDPAGE_H

第二页cpp:

//Second Page cpp file
#include "secondpage.h"
#include "ui_secondpage.h"
#include "thirdpage.h"

SecondPage::SecondPage(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::SecondPage)
{
    ui->setupUi(this);
    //setFixedSize(854,480);
    setMinimumSize(854,480);
}

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

void SecondPage::on_pushButton_clicked()
{
    QString nameOfClient = ui->NameOfClient->text();
    QString designation = ui->DesignationOfCompany->text();
    QString nameOfCompany = ui->NameOfIndustry->text();
    QString addressOfCompany = ui->Address->text();
    QString contactNumber = ui->ContactNumber->text();
    QString annualProductionCapacity = ui->AnnualProductionCapacity->text();

    QString clientDetails[6] = {nameOfClient,designation,nameOfCompany,addressOfCompany,contactNumber,};

    hide();
    thirdPage = new ThirdPage(this);
    thirdPage->show();
}

我得到的错误是在thirdpage.h中:

error: 'SecondPage' does not name a type
     SecondPage *secPage;
     ^

任何人都可以看到问题所在?

0 个答案:

没有答案