C++ QT Creator:简单程序的未解析外部符号和外部错误

C++ QT Creator:简单程序的未解析外部符号和外部错误,c++,qt,C++,Qt,我正处于学习Q Creator的阶段,并遵循教程,当我尝试编译时,返回了以下错误: moc_mainwindow.obj:-1:错误:LNK2019:未解析的外部符号“私有:无效uuu cdecl mainwindow::on_actionNew_Window_triggered(无效)”(?on_actionNew_Window_triggered@MainWindow@@AEAAXXZ)在函数“private:static void\uu cdecl main window::qt\u st

我正处于学习Q Creator的阶段,并遵循教程,当我尝试编译时,返回了以下错误:

moc_mainwindow.obj:-1:错误:LNK2019:未解析的外部符号“私有:无效uuu cdecl mainwindow::on_actionNew_Window_triggered(无效)”(?on_actionNew_Window_triggered@MainWindow@@AEAAXXZ)在函数“private:static void\uu cdecl main window::qt\u static\u metacall(类QObject*,枚举QMetaObject::Call,int,void**”中引用(?qt_静态_metacall@MainWindow@@CAXPEAVQObject@@W4Call@QMetaObject@@HPEAPEAX@Z)

以及:

debug\Program5--显示DifferentingTwinDowTypes.exe:-1:错误:LNK1120: 1未解决的外部问题

我已经有了一些其他的程序可以正常工作,但我在这个程序中做的不同之处在于我创建了一个新的表单,这样我就可以测试创建一个模态和非模态窗口

我已经尝试过右键单击项目文件,然后进行清理、构建qmake和运行——我已经在这里看到了解决方案

下面是我认为可能导致问题的代码,但我不能完全确定

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "modaldialog.h" //Need to include for each new file you make; Basic C++ rules apply.

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //This sets the main portion of the window to whatever Qobject is inside of it.
    setCentralWidget(ui->plainTextEdit);
}

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

//Creates a Dialog Window that cannot be clicked out out of unless closed.
void MainWindow::on_actionModal_Window_triggered()
{
    ModalDialog mDialog;
    mDialog.setModal(true);
    mDialog.exec();
}

如果您需要任何其他文件,请告诉我,但这是我实际添加代码的唯一文件。

您缺少
MainWindow::on\u actionNew\u Window\u triggered()的定义
在您的cpp文件中。

显示MainWindow.h请确认,这就成功了!我不敢相信这么长的错误代码的解决方案这么容易修复。