Qt简单的文本编辑器,有什么问题吗?

Qt simple text editor, what's wrong?

我正在使用他们的文本编辑器学习 Qt 基础知识 tutorial

我无法弄清楚我在 main() 中的代码有什么问题。我遇到以下错误:

linker command failed with exit code 1 (use -v to see invocation)

symbol(s) not found for architecture x86_64

这是我的代码:

class TextEditor : public QWidget
{
    Q_OBJECT

public:
    TextEditor();

private slots:
    void quit();

private:
    QTextEdit *textEdit;
    QPushButton *quitButton;
};

TextEditor::TextEditor()
{
    textEdit = new QTextEdit;
    quitButton = new QPushButton(tr("Quit"));

    connect(quitButton, SIGNAL(clicked()), this, SLOT(quit()));

    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(textEdit);
    layout->addWidget(quitButton);

    setLayout(layout);

    setWindowTitle(tr("TextEditor"));
}

void TextEditor::quit()
{
    QMessageBox messageBox;
    messageBox.setWindowTitle(tr("TextEditor"));
    messageBox.setText(tr("Really?"));
    messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
    messageBox.setDefaultButton(QMessageBox::No);
    if (messageBox.exec() == QMessageBox::Yes)
        qApp->quit();
}

int main (int argc, char *argv[])
{
    QApplication app(argc, argv);

    TextEditor w;
    w.show();

    return app.exec();
}

在源文件底部添加以下内容。

#include "main.moc"

然后build->run qmake然后build->rebuild