【发布时间】:2018-05-20 11:04:53
【问题描述】:
我正在尝试制作一个虚假的 FBI 程序来进行恶作剧,但这并不像我预期的那么容易。 这是我的代码。
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->trackConnButton->setEnabled(false);
}
void MainWindow::on_confirmButton_clicked() {
if (ui->usernameText == "name" && ui->passwordText == "password") {
ui->resullabel->setText("Password accepted.");
ui->trackConnButton->setEnabled(true);
} else {
ui->resullabel->setText("Password denied.");
}
}
MainWindow::~MainWindow()
{
delete ui;
}
我得到这个错误:
D:\Qt-Projekte\test3\mainwindow.cpp:12: Fehler: no 'void MainWindow::on_confirmButton_clicked()' member function declared in class 'MainWindow'
void MainWindow::on_confirmButton_clicked() {
^
我现在的问题是:如何解决? 提前致谢。
我的主窗口.h:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
【问题讨论】:
-
询问编译错误时:请复制粘贴错误文本,而不是解释它。
-
向我们展示
MainWindow类的定义(大概在mainwindow.h中)。您似乎忘记了on_confirmButton_clicked的函数声明。 -
@0x5453 完成,我希望没问题。
-
@1hund 他们的问题已经回答了您的问题(您是否阅读了整个评论,还是只阅读了第一句话?)。
MainWindow中没有on_confirmButton_clicked的声明。