04/26课后作业(C++)

#include "lander.h"
#include "ui_lander.h"

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

    ///
    /*窗口*/
    this->setFixedSize(530,400);       
    this->setWindowIcon(QIcon(":/icon/01.jpg"));
    this->setWindowTitle("析木");
    this->setStyleSheet("background-color:white;");

    ///
    /*logo*/
    this->lable1 = new QLabel(this);
    this->lable1->move(190,0);
    this->lable1->resize(150,150);
    this->lable1->setScaledContents(true);     
    this->lable1->setPixmap(QPixmap(":/icon/01.jpg"));

    ///
    /*账户*/
    this->lable2 = new QLabel(this);
    this->lable2->move(120,180);
    this->lable2->resize(30,30);
    this->lable2->setScaledContents(true);
    this->lable2->setPixmap(QPixmap(":/icon/zhanghu.png"));

    ui->userNameEdit->move(170,180);
    ui->userNameEdit->resize(220,30);
    ui->userNameEdit->setPlaceholderText("账户");         

    ///
    /*密码*/
    this->lable3 = new QLabel(this);
    this->lable3->move(120,230);
    this->lable3->resize(30,30);
    this->lable3->setScaledContents(true);
    this->lable3->setPixmap(QPixmap(":/icon/mima.png"));

    ui->pwdEdit->move(170,230);
    ui->pwdEdit->resize(220,30);
    ui->pwdEdit->setPlaceholderText("密码");
    ui->pwdEdit->setEchoMode(QLineEdit::Password);         

    ///
    /*登录*/
    ui->loginBtn->move(170,280);
    ui->loginBtn->resize(100,30);
    ui->loginBtn->setStyleSheet("background-color:light gray;");

    /*取消*/
    ui->cancelBtn->move(290,280);
    ui->cancelBtn->resize(100,30);
    ui->cancelBtn->setStyleSheet("background-color:light gray;");
    //    ui->cancelBtn->setEnabled(false);

    ///
    /*手动连接信号*/
    connect(ui->loginBtn,&QPushButton::clicked,this,&lander::my_loginBtn_clicked);          
}

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

//自定义的处理loginBtn的函数
void lander::my_loginBtn_clicked()
{
    QString userName = ui->userNameEdit->text();
    QString pwd = ui->pwdEdit->text();
    if(userName == "xx" && pwd == "123")
    {
        qDebug() << "登陆成功!";
        this->close();
    }
    else
    {
        qDebug() << "登陆失败!";
        ui->pwdEdit->clear();
    }
}

void lander::on_cancelBtn_clicked()
{
    this->close();
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值