在登录界面的登录取消按钮进行一下设置:
使用手动连接,将登录框中的取消按钮使用qt4版本的连接到自定义的槽函数中,在自定义的槽函数中调用关闭函数将登录按钮使用qt5版本的连接到自定义的槽函数中,在槽函数中判断ui界面上输入的账号是否为"admin",密码是否为"123456",如
l果账号密码匹配成功,则输出“登录成功",并关闭该界面,如果匹配失败,则输出登录失败,并将密码框中的内容清空
#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QMessageBox>
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget),m_pspeaker(NULL)
{
ui->setupUi(this);
this->setWindowFlag(Qt::FramelessWindowHint);
m_pspeaker = new QTextToSpeech(this);
connect(ui->ToolBLogin,SIGNAL(clicked()),this,SLOT(speakerClick()));
}
Widget::~Widget()
{
delete ui;
if(NULL != m_pspeaker) delete m_pspeaker;
}
void Widget::on_PushBOK_clicked()
{
//qDebug()<<"1";
QString strName = ui->LineELogin->text();
QString strPass = ui->LineEPassword->text();
if(strName == QString("admin") && strPass == QString("123456")){
m_pspeaker->say("登陆成功");
QMessageBox::about(this, "登录", "登陆成功");
this->close();
}else{
m_pspeaker->say("登陆失败");
QMessageBox::about(this, "登录", "登陆失败");
ui->LineEPassword->clear();
}
}
void Widget::on_PushBForget_pressed()
{
ui->PushBForget->setStyleSheet("border-radius:8px;text-decoration: underline;color:rgb(0,0,0)");
}
void Widget::on_PushBForget_released()
{
ui->PushBForget->setStyleSheet("border-radius:8px;text-decoration: underline;");
}
void Widget::on_PushBCreate_pressed()
{
ui->PushBCreate->setStyleSheet("border-radius:8px;text-decoration: underline;color:rgb(0,0,0)");
}
void Widget::on_PushBCreate_released()
{
ui->PushBCreate->setStyleSheet("border-radius:8px;text-decoration: underline;");
}
void Widget::on_PushBOK_pressed()
{
ui->PushBOK->setStyleSheet("border-radius:8px;background-color:rgb(102, 255, 239);color:rgb(0,0,0)");
}
void Widget::on_PushBOK_released()
{
ui->PushBOK->setStyleSheet("border-radius:8px;background-color:rgb(92, 255, 209);");
}
void Widget::speakerClick()
{
this->close();
}
void Widget::on_ToolBClose_clicked()
{
this->close();
}
思维导图