#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
this->setWindowTitle("QQ"); //title
this->setWindowIcon(QIcon(":/icon/login.png")); //icon
this->setFixedSize(800, 600); //设置固定格式
button_loin = new QPushButton(this);
button_loin->setText("登录");
button_loin->move(230, 500);
button_exit = new QPushButton(this);
button_exit->setText("退出");
button_exit->move(430, 500);
label_loin = new QLabel(this);
label_loin->resize(50, 50);
label_loin->setScaledContents(true); //设置图片自适应标签大小
label_loin->setPixmap(QPixmap(":/icon/userName.jpg"));
label_loin->move(200, 300);
label_password = new QLabel(this);
label_password->resize(50, 50);
label_password->setScaledContents(true); //设置图片自适应标签大小
label_password->setPixmap(QPixmap(":/icon/passwd.jpg"));
label_password->move(200, 400);
label_logo = new QLabel(this);
label_logo->resize(800, 200);
label_logo->setScaledContents(true); //设置图片自适应标签大小
label_logo->setPixmap(QPixmap(":/icon/logo.png"));
line_user = new QLineEdit(this);
line_user->move(270, 300);
line_user->setPlaceholderText("账户"); //设置占文文本
line_password = new QLineEdit(this);
line_password->move(270, 400);
line_password->setPlaceholderText("密码"); //设置占文文本
line_password->setEchoMode(QLineEdit::Password); //设置密文模式
//qt 4.0版本的连接, 即使信号函数和槽函数写错了, 也不报错, 只是运行时没有效果
//将按钮loin的clicked信号, 连接到自定义的槽函数里, 处理相关逻辑
//connect(this->button_exit, SIGNAL(clicked()), this, SLOT(my_solt()));
//connect(this->button_loin, SIGNAL(clicked()), this, SLOT(loin_solt()));
speech = new QTextToSpeech(this);
//qt 5.0版本的连接,
//connect(this->button_exit, &QPushButton::clicked, this, &Widget::my_solt1);
//connect(this->button_loin, &QPushButton::clicked, this, &Widget::my_solt2);
connect(button_exit, &QPushButton::clicked, [&](){
this->close();
});
}
Widget::~Widget()
{
delete ui;
}
/*
//自定义的槽函数
void Widget::my_solt()
{
this->close();
}
void Widget::loin_solt()
{
if (this->line_user->text() == QString("admire") && this->line_password->text() == QString("123456"))
{
qDebug() << "登录";
}
else
{
this->line_password->setText("");
qDebug() << "失败";
}
}
*/
/*
void Widget::my_solt1()
{
this->close();
}
void Widget::my_solt2()
{
if (this->line_user->text() == QString("admire") && this->line_password->text() == QString("123456"))
{
qDebug() << "登录成功";
speech->say(QString("登录成功"));
}
else
{
qDebug() << "登陆失败";
}
}
*/