10.19QT作业

#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    //标签
    ui->label2->setPixmap(QPixmap("D:\\QT\\picture\\OIP-C.png"));
    ui->label2->setScaledContents(true);

    ui->label->setPixmap(QPixmap("D:\\QT\\picture\\rose.jpg"));
    ui->label->setScaledContents(true);
    //账号密码
    ui->led1->setPlaceholderText("QQ账号/手机号码/QQ邮箱");
    ui->led2->setPlaceholderText("密码");
    ui->led2->setEchoMode(QLineEdit::Password);

//    connect(ui->btn2,SIGNAL(clicked()),this,SLOT(my_close()));
//    connect(ui->btn1,&QPushButton::clicke,this,&Widget::My_slot);
    connect(ui->btn1, &QPushButton::clicked, this, &Widget::My_slot);
    connect(ui->btn2, &QPushButton::clicked, this, &Widget::my_close);

}
void Widget::My_slot()
{
    if("hhh" == ui->led1->text())
    {
        if("123456" == ui->led2->text())
        {
              QMessageBox msg(QMessageBox::NoIcon,
                              "可喜可贺",
                              "进去嗨吧,别玩噶了",
                              QMessageBox::Ok,
                              this);
              int ret = msg.exec();
              if(ret == QMessageBox::Ok)
              {
                    //跳转
                  emit jump();
                  this->close();
              }


        }
    }
    else
    {

        QMessageBox msg(QMessageBox::Critical,
                        "很遗憾",
                        "账号密码不匹配,是否重新登录",
                        QMessageBox::Yes | QMessageBox::No,
                        this);

        int ret = msg.exec();
        if(ret == QMessageBox::Yes)
        {
             ui->led2->clear();
        }else if(ret == QMessageBox::No)
        {
            this->close();
        }

    }


}
void Widget::my_close()
{
    QMessageBox msg(QMessageBox::Question,
                    "我有问题",
                    "确定要退出登录?",
                    QMessageBox::Yes | QMessageBox::No,
                    this);
    int ret = msg.exec();
    if(ret == QMessageBox::Yes)
    {
         this->close();

    }

}

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

你可能感兴趣的:(qt)