QTday3

#include "mywidget.h"
#include "ui_mywidget.h"

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

    //窗口的相关设置
    this->setWindowTitle("QQ");
    this->setWindowIcon(QIcon(":/pictrue/wodepeizhenshi.png"));

    //标签的相关设置
    ui->logoLab->setPixmap(QPixmap(":/pictrue/logo.png"));
    ui->logoLab->setScaledContents(true);

    //账号和密码
    ui->userNameLab->resize(20,20);
    ui->userNameLab->setPixmap(QPixmap(":/pictrue/name.jpg"));
    ui->userNameLab->setScaledContents(true);

    ui->passwdLab->resize(20,20);
    ui->passwdLab->setPixmap(QPixmap(":/pictrue/passwd.jpg"));
    ui->passwdLab->setScaledContents(true);

    ui->userNameEdit->setPlaceholderText("QQ账号");
    ui->passwdEdit->setEchoMode(QLineEdit::Password);

    ui->loginBtn->setIcon(QIcon(":/pictrue/login.png"));
    ui->cancelBtn->setIcon(QIcon(":/pictrue/cancel.png"));

    connect(ui->cancelBtn,SIGNAL(clicked()),this,SLOT(Slot_cancelBtn()));
    connect(ui->loginBtn,&QPushButton::clicked,this,&MyWidget::Slot_loginBtn);
}

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

void MyWidget::Slot_cancelBtn()
{
    int ret=QMessageBox::question(this,"问题","您是否确定要退出登录?",QMessageBox::Yes|QMessageBox::No);
    if(ret==QMessageBox::Yes)
        this->close();
}

void MyWidget::Slot_loginBtn()
{
    if(ui->userNameEdit->text()=="admin" && ui->passwdEdit->text()=="123456")
    {
        QMessageBox info(QMessageBox::Information,"信息","登录成功",QMessageBox::Ok);
        int ret = info.exec();
        if(ret==QMessageBox::Ok)
        {
            this->close();
            emit loginBtn_signal();
        }
    }
    else
    {
        int ret= QMessageBox::critical(this,"错误","账号和密码不匹配,是否重新登录",QMessageBox::Yes|QMessageBox::No);
        if(ret==QMessageBox::Yes)
            ui->passwdEdit->clear();
        else
            this->close();
    }

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值