Qt作业八

#include "qq_picture.h"
#include "ui_qq_picture.h"

QQ_picture::QQ_picture(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::QQ_picture)
{
    ui->setupUi(this);
    setWindowFlag(Qt::FramelessWindowHint);
    setWindowTitle("QQ聊天");
    //设置动态背景
    QMovie *mv=new QMovie("D:\\QT\\QT\\1.gif");
    ui->label->setMovie(mv);
    mv->start();
    ui->close->setStyleSheet("background-color:transparent");
    //设置密码为隐秘
    ui->lineEdit_3->setEchoMode(QLineEdit::Password);
    //用QT4关闭
    connect(ui->pushButton_2,&QPushButton::clicked,this,&QQ_picture::close_slot);
    //用QT5登录
    connect(ui->pushButton, &QPushButton::clicked, this, &QQ_picture::my_slot);
}

void QQ_picture::close_slot()
{
    //基于静态成员函数
    QQ_picture::on_pushButton_2_clicked();
}

void QQ_picture::my_slot()
{
    QString name = ui->lineEdit_2->text();
    QString password = ui->lineEdit_3->text();
    if(name == "cmx" && password == "201613320")
    {
        close();//关闭页面
        emit jump_signal();//跳转信号
    }
    else
    {
        //基于属性
        QQ_picture::on_pushButton_clicked();
    }

}

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


void QQ_picture::on_pushButton_clicked()
{
    QMessageBox msg(QMessageBox::Warning,
                    "警告",
                    "账号与密码不匹配,是否重新登录",
                    QMessageBox::Yes | QMessageBox::No,
                    this);
    int ret = msg.exec();

    if(ret==QMessageBox::Yes)//点击yes操作
    {
        ui->lineEdit_3->clear();
    }
    else
    {
        close();//点击no操作
    }
}

void QQ_picture::on_pushButton_2_clicked()
{
    //直接调用静态成员函数
    int ret = QMessageBox::question(this,
                                    "问题",
                                    "您是否确定要退出登录",
                                    QMessageBox::Yes | QMessageBox::No);

    //判断用户选的按钮
    if(ret==QMessageBox::Yes)
    {
        ui->
    }
    else
    {
        this->close();
    }
}

你可能感兴趣的:(qt,开发语言)