运行mainwindowm.cpp总是会出现这样的问题
**QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked() **
运行出来的窗口输入账号和密码,点击登录按钮,并没有显示出来,怎么样修改才能显示出来呢?
.h文件
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QWidget>
#include <QString>
#include <QDebug>
#include <QMainWindow>
#include <database.h>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
database myDatabase;
MainWindow(QWidget *parent = nullptr);
~MainWindow();
signals:
void try_login();
private slots:
void on_pushButton_clicked();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
.cpp文件
```c++
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QApplication>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->myDatabase.getConnection();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow:: on_pushButton_clicked()
{
QString userInputtype;
if(ui->radioButton_2->isChecked())
{
userInputtype = "counter";
}
else
{
userInputtype = "manager";
}
QString userInputNumber = ui->InputNumber->text();
QString userInputPassWord = ui->InputPassWord->text();
qDebug()<<"用户输入的账号"+userInputNumber;
qDebug()<<"用户输入的密码"+userInputPassWord;
}