//界面1 头文件
signals:
//界面1的自定义信号
void my_signal();
private slots:
void on_pushButton_2_clicked();
void on_pushButton_clicked();
//界面1 .cpp文件
void Widget::on_pushButton_2_clicked()
{
QMessageBox msg(QMessageBox::Warning,
"警告",
"是否退出",
QMessageBox::Yes| QMessageBox::No,
this
);
int ret= msg.exec();
if(ret==QMessageBox::Yes)
{
this->close();
}
else
{
}
}
void Widget::on_pushButton_clicked()
{
if(ui->lineEdit->text()=="admin"&&ui->lineEdit_2->text()=="123456")
{
QMessageBox msg(QMessageBox::Warning,
"提示",
"登录成功",
QMessageBox::Yes,
this
);
int ret= msg.exec();
if(ret==QMessageBox::Yes)
{
this->close();
emit my_signal();
}
}
else
{
QMessageBox msg(QMessageBox::Warning,
"提示",
"账户密码输入错误",
QMessageBox::No,
this
);
int ret= msg.exec();
if(ret==QMessageBox::No)
{
ui->lineEdit->clear();
ui->lineEdit_2->clear();
}
}
}
//主函数
#include "widget.h"
#include"talk.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
Talk t;
QObject::connect(&w,&Widget::my_signal,&t,&Talk::my_slot);
w.show();
return a.exec();
}