#include "my_widget.h"
#include "ui_my_widget.h"
My_Widget::My_Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::My_Widget)
{
ui->setupUi(this);
//窗口的相关设置
// this -> resize(800,500);
this -> setWindowTitle("QQ聊天");
this -> setWindowIcon(QIcon(":/pictrue/pictrue/qq.png"));
//标签相关设置
ui-> logoLab ->setPixmap(QPixmap(":/pictrue/pictrue/logo.png"));
ui -> logoLab -> setScaledContents(true);
//账号和密码
ui -> userNameLab -> resize(40,40);
ui -> userNameLab -> setPixmap(QPixmap(":/pictrue/pictrue/wodepeizhenshi.png"));
ui -> userNameLab -> setScaledContents(true);
ui -> passwdLab -> resize(40,40);
ui -> passwdLab ->setPixmap(QPixmap(":/pictrue/pictrue/passwd.jpg"));
ui -> passwdLab ->setScaledContents(true);
//账号密码输入
ui -> usrEdit ->setPlaceholderText("QQ账号/手机号码/QQ邮箱");
ui -> passwdEdit -> setPlaceholderText("请输入密码");
ui -> passwdEdit -> setEchoMode(QLineEdit::Password);
//登录按钮
ui -> btn1 ->setIcon(QIcon(":/pictrue/pictrue/login.png"));
ui -> btn2 ->setIcon(QIcon(":/pictrue/pictrue/cancel.png"));
connect(ui ->btn1,&QPushButton::clicked,this,&My_Widget::btn1_slot);
connect(ui->btn2,SIGNAL(clicked()),this,SLOT(my_slot()));
}
My_Widget::~My_Widget()
{
delete ui;
}
void My_Widget::my_slot()
{
this ->close();
}
void My_Widget:: btn1_slot()
{
QString s = ui ->usrEdit->text();//存入输入的数据
QString v = ui ->passwdEdit->text();//存入输入的数据
//判断输入是否正确
if(s=="admin"&&v=="123456")
{
qDebug() << "登录成功";
this->close();
}
else
{
qDebug() << "登录失败,请正确输入" ;
ui ->usrEdit->clear();
ui->passwdEdit -> clear();
}
}