#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
,btn(new QPushButton("取消", this))
,login_btn(new QPushButton("登录", this))
{
ui->setupUi(this);
this -> setWindowIcon(QIcon(":/picture/hp.jpg"));//设置窗口图标
this -> setWindowFlag(Qt::FramelessWindowHint, 1);//无边框
//设置窗口动图
QMovie *mv = new QMovie(":/picture/ht.webp");
ui ->label-> setMovie(mv);
mv -> start();
ui -> label -> setScaledContents(true);
//设置退出按钮连接窗口关闭
btn -> resize(ui -> btn2 -> width(), ui -> btn2 -> height());
btn->move(ui->btn2->x(), ui->btn2->y()+ui->btn2->height() + 6);
connect(btn, SIGNAL(clicked()), this, SLOT(my_slots()));
//设置登录按钮连接登录
login_btn -> resize(ui -> btn2 -> width(), ui -> btn2 -> height());
login_btn->move(ui->btn2->x(), ui->btn2->y()+ui->btn2->height() - 29);
connect(login_btn, &QPushButton::clicked, this, &Widget::login_slot);
//设置行编辑器的文本及文本显示模式
ui -> ac_line -> setPlaceholderText("CC账号");
ui -> pa_line -> setPlaceholderText("CC密码");
ui -> ac_line -> setEchoMode(QLineEdit::Normal);
ui -> pa_line -> setEchoMode(QLineEdit::Password);
}
Widget::~Widget()
{
delete ui;
}
void Widget::my_slots(){
this -> close();
}
void Widget::on_btn1_clicked()
{
this -> close();
}
void Widget::login_slot(){
if(ui -> ac_line -> text() == "admin"){
if(ui -> pa_line -> text() == "123456"){
qDebug() << "登录成功";
}
}else{
qDebug() << "账号或密码错误";
ui -> pa_line -> setText("");
}
}
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QLabel>
#include <QMovie>
#include <QIcon>
#include <QObject>
#include <QPushButton>
#include <QDebug>
QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = nullptr);
~Widget();
signals:
void my_singal();
private slots:
void on_btn1_clicked();
void my_slots();
void login_slot();
private:
Ui::Widget *ui;
QPushButton *btn;
QPushButton *login_btn;
};
#endif // WIDGET_H