您好,我不断收到此错误:'{' token { ^ 第 15 行之前的预期类名这个错误到底是什么意思?我试图继承具有我需要在 form1 的 cpp 中调用的函数的控制器类。
#ifndef FORM1_H
#define FORM1_H
#include <QDialog>
#include "controller.h"
namespace Ui {
class form1 ;
}
class form1 : public QDialog, public controller
{
Q_OBJECT
public:
explicit form1(QWidget *parent = 0);
~form1();
private slots:
void on_pushButton_clicked();
private:
Ui::form1 *ui;
};
#endif // FORM1_H
控制器类
#include "controller.h"
#include "ui_controller.h"
controller::controller(QWidget *parent) :
QWidget(parent),
ui(new Ui::controller) {
ui->setupUi(this);
show(1); }
void controller::show(int x) {
if(x==1)
{
myform1 = new form1(this);
myform1->show();
}
if(x==2)
{
myform2 = new form2(this);
myform2->show();
}
if(x==3)
{
myform3 = new form3(this);
myform3->show();
} }
controller::~controller() {
delete ui; }
控制器.h:
#ifndef CONTROLLER_H
#define CONTROLLER_H
#include <QWidget>
#include <form1.h>
#include <form2.h>
#include <form3.h>
namespace Ui {
class controller;
}
class controller : public QWidget
{
Q_OBJECT
public:
form1 * myform1;
form2 * myform2;
form3 * myform3;
void show(int x);
explicit controller(QWidget *parent = 0);
~controller();
private:
Ui::controller *ui;
};
#endif // CONTROLLER_H