#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
this->setFixedSize(800,700);//设置固定尺寸
qDebug()<<this->windowTitle(); //获取窗口标题
this->setWindowTitle("hqyj"); //设置窗口标题
this->setWindowIcon(QIcon("E:/c++qt/qtday02/icon.png"));//设置窗口图标
this->setStyleSheet("background-color:pink;"); //设置背景颜色
//实例化一个标签 (最大的)
l1 = new QLabel("第一个标签",this);
l1->resize(800,200);
l1->move(0,0);
l1->setScaledContents(true); //设置图片自适应的标签大小
l1->setPixmap(QPixmap("E:\\c++qt\\qtday02\\hi"));
//定义登录按钮
b1=new QPushButton(QIcon("E:\\c++qt\\qtday02\\icon\\login.png"),"登录",this);
b1->move(300,400); //固定位置
b1->resize(50,50); //设置大小
//定义取消按钮
b2=new QPushButton(QIcon("E:\\c++qt\\qtday02\\icon\\cancle.png"),"取消",this);
b2->move(400,400); //固定位置
b2->resize(b1->size()); //设置大小
//实例化一个标签 账户名
l2=new QLabel("第二个标签",this);
l2->move(200,300);
l2->resize(50,30);
l2->setScaledContents(true); //设置图片自适应大小
l2->setStyleSheet("background-color:yellow"); //设置颜色黄色
l2->setPixmap(QPixmap("E:\\c++qt\\qtday02\\icon\\userName.jpg"));
//实例化一个标签作为 密码
l3=new QLabel("第三个标签",this);
l3->move(200,350);
l3->resize(50,30);
l3->setScaledContents(true); //设置图片自适应大小
l3->setStyleSheet("background-color:bule"); //设置颜色蓝色
l3->setPixmap(QPixmap("E:\\c++qt\\qtday02\\icon\\passwd.jpg"));
//实例化一个编辑器作为输入账户
le1=new QLineEdit(this);
le1->move(300,300);
le1->resize(200,30);
//设置回显模式
le1->setEchoMode(QLineEdit::Normal); //设置正常模式
le1->setPlaceholderText("账号/手机/邮箱");
le1->setStyleSheet("background-color:yellow"); //设置为黄色
//实例化一个编辑器作为输入密码
le2=new QLineEdit(this);
le2->move(300,350);
le2->resize(200,30);
//设置回显模式
le2->setEchoMode(QLineEdit::Password); //设置正常模式
le2->setPlaceholderText("密码");
le2->setStyleSheet("background-color:red"); //设置为红色
speech =new QTextToSpeech(this);
//speech->say();
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_b2()
{
this->close();
}
void Widget::my_solt()
{
if(this->le1->text()=="LOL"&&this->le2->text()=="112233")
{
qDebug()<<"登陆成功";
this->close();
}else
{
qDebug()<<"登陆失败";
this->le2->clear();
}
}