#include "widget.h"
#include "ui_widget.h"Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui->setupUi(this);//==============窗口相关设置=======this->resize(540,415);this->setFixedSize(540,415);//窗口标题this->setWindowTitle("盗版QQ");//窗口图标this->setWindowIcon(QIcon(":/C:/Users/ShiSS/Desktop/pictrue/qq.png"));//背景颜色this->setStyleSheet("background-color:white");//去掉头部//this->setWindowFlag(Qt::FramelessWindowHint);//============标签相关设置=======QLabel *lab1 = new QLabel(this);//设置大小lab1->resize(540, 160);lab1->setStyleSheet("background-color:pink");//动图类 接收动图QMovie *mv = new QMovie(":/C:/Users/ShiSS/Desktop/pictrue/zz.gif");//将动图放入标签中lab1->setMovie(mv);//让动图动起来mv->start();//自动适应lab1->setScaledContents(true);QLabel *lab2 = new QLabel(this);lab2->resize(30,30);lab2->move(120,210);lab2->setPixmap(QPixmap(":/C:/Users/ShiSS/Desktop/pictrue/wodepeizhenshi.png"));lab2->setScaledContents(true);QLabel *lab3 = new QLabel(this);lab3->resize(30,30);lab3->move(120, 260);lab3->setPixmap(QPixmap(":/C:/Users/ShiSS/Desktop/pictrue/passwd.jpg"));lab3->setScaledContents(true);//============行编辑器相关设置=======edit1 = new QLineEdit(this);edit1->resize(275,30);edit1->move(155,210);edit1->setPlaceholderText("QQ号/手机号/邮箱");edit2 = new QLineEdit(this);edit2->resize(275,30);edit2->move(155,260);edit2->setPlaceholderText("密码");edit2->setEchoMode(QLineEdit::Password);//============按钮相关设置=======btn = new QPushButton("登录",this);btn->resize(300,45);btn->move(120,345);//样式函数setStyleSheet()btn->setStyleSheet("background-color:red;border-radius:5px;color:white");//使用连接函数,将按钮连接到自定义槽函数中connect(this->btn,&QPushButton::clicked,this,&Widget::btn_clicked);//使用连接函数,将输入字符长度连接到自定义槽函数中connect(this->edit1,&QLineEdit::textChanged,this,&Widget::size_long);connect(this->edit2,&QLineEdit::textChanged,this,&Widget::size_long);
}
Widget::~Widget()
{delete ui;
}
//登陆槽函数
void Widget::btn_clicked()
{if(edit1->text()=="Admin" && edit2->text()=="123456"){qDebug()<< "登陆成功";this->close();}else{qDebug() << "登陆失败,请检查账号或密码";edit2->clear();}
}
//按钮变色槽函数
void Widget::size_long()
{if(edit1->text().size()>=5 && edit2->text().size()>=5){this->btn->setEnabled(true);this->btn->setStyleSheet("background-color:rgb(8,189,253)");}else{this->btn->setEnabled(false);this->btn->setStyleSheet("background-color:red");}
}