12/11

 form 构造函数

#include "form.h"
#include "ui_form.h"

Form::Form(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Form)
{
    ui->setupUi(this);
    this->setWindowIcon(QIcon(":/pictrue/zaoyo.jpg"));
    this->setWindowFlag(Qt::FramelessWindowHint);
    this->setFixedSize(400,640);
    QMovie *mv=new QMovie(":/pictrue/wendi.gif");
    ui->mvlab->setMovie(mv);
    ui->mvlab->setScaledContents(true);
    mv->start();
    this->setAttribute(Qt::WA_TranslucentBackground);


}

Form::~Form()
{
    delete ui;
}

void Form::jump_slots()
{
    this->show();
}

 widget 构造函数

#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    this->resize(741,611);

    this->setWindowIcon(QIcon(":/pictrue/qq.png"));

    this->setWindowTitle("盗版QQ");

    this->setWindowFlag(Qt::FramelessWindowHint);

    QMovie *mv=new QMovie(":/pictrue/hutao.gif"); //设置动态图
    ui->headplab->setMovie(mv);
    ui->headplab->setScaledContents(true);
    mv->start();

    ui->logelab->setPixmap(QPixmap(":/pictrue/OIP-C.jpg"));
    ui->logelab->setScaledContents(true);

    QMovie *mv1=new QMovie(":/pictrue/qq2.gif");
    ui->backgroundlab->setMovie(mv1);
    ui->backgroundlab->setScaledContents(true);
    mv1->start();

    ui->usrnamelab->setPixmap(QPixmap(":/pictrue/userName.jpg"));
    ui->usrnamelab->setScaledContents(true);
    ui->usrnameline->setPlaceholderText("QQ账号");

    ui->passwdlab->setPixmap(QPixmap(":/pictrue/suo.jpg"));
    ui->passwdlab->setScaledContents(true);
    ui->passwdline->setPlaceholderText("QQ密码");
    ui->passwdline->setEchoMode(QLineEdit::Password);

    connect(ui->endbut,SIGNAL(clicked()),this,SLOT(my_endbut()));
   // connect(ui->loginbut,SIGNAL(clicked()),this,SLOT(my_login()));


}

Widget::~Widget()
{
    delete ui;
}

void Widget::my_endbut()
{
    this->close();
}

void Widget::my_login()
{
    if(ui->passwdline->text()=="admin" && ui->usrnameline->text()=="123456")
    {
        qDebug() << "登入成功" ;
        this->close();
    }
    else
    {
        qDebug() << "登入失败" ;
    }
}

void Widget::on_loginbut_clicked()
{

    if(ui->passwdline->text()=="admin" && ui->usrnameline->text()=="123456")
    {
        QMessageBox::information(this,"盗版QQ","登入成功",QMessageBox::Yes);

        qDebug() << "登入成功" ;
        emit jump_signals();
        this->close();
    }
    else
    {
        qDebug() << "登入失败" ;
        ui->usrnameline->clear();
        ui->passwdline->clear();
        QMessageBox::information(this,"盗版QQ","登入失败,请重新登入",QMessageBox::Yes);
    }

}

 

你可能感兴趣的:(命令模式)