qt作业 登录

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

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    this->setFixedSize(800,700);//设置固定尺寸
    qDebug()<<this->windowTitle();  //获取窗口标题
    this->setWindowTitle("hqyj");    //设置窗口标题
    this->setWindowIcon(QIcon("E:/c++qt/qtday02/icon.png"));//设置窗口图标
    this->setStyleSheet("background-color:pink;");  //设置背景颜色
    //实例化一个标签  (最大的)
    l1 = new QLabel("第一个标签",this);
    l1->resize(800,200);
    l1->move(0,0);
    l1->setScaledContents(true);   //设置图片自适应的标签大小
    l1->setPixmap(QPixmap("E:\\c++qt\\qtday02\\hi"));

    //定义登录按钮
      b1=new QPushButton(QIcon("E:\\c++qt\\qtday02\\icon\\login.png"),"登录",this);
      b1->move(300,400);  //固定位置
      b1->resize(50,50);  //设置大小

      //定义取消按钮
      b2=new QPushButton(QIcon("E:\\c++qt\\qtday02\\icon\\cancle.png"),"取消",this);
      b2->move(400,400);  //固定位置
      b2->resize(b1->size());  //设置大小

      //实例化一个标签 账户名
      l2=new QLabel("第二个标签",this);
      l2->move(200,300);
      l2->resize(50,30);
      l2->setScaledContents(true);    //设置图片自适应大小
      l2->setStyleSheet("background-color:yellow");   //设置颜色黄色
      l2->setPixmap(QPixmap("E:\\c++qt\\qtday02\\icon\\userName.jpg"));


      //实例化一个标签作为 密码
      l3=new QLabel("第三个标签",this);
      l3->move(200,350);
      l3->resize(50,30);
      l3->setScaledContents(true);    //设置图片自适应大小
      l3->setStyleSheet("background-color:bule");   //设置颜色蓝色
      l3->setPixmap(QPixmap("E:\\c++qt\\qtday02\\icon\\passwd.jpg"));

      //实例化一个编辑器作为输入账户
      le1=new QLineEdit(this);
      le1->move(300,300);
      le1->resize(200,30);
         //设置回显模式
      le1->setEchoMode(QLineEdit::Normal);    //设置正常模式
      le1->setPlaceholderText("账号/手机/邮箱");
      le1->setStyleSheet("background-color:yellow");  //设置为黄色
      //实例化一个编辑器作为输入密码
      le2=new QLineEdit(this);
      le2->move(300,350);
      le2->resize(200,30);
        //设置回显模式
      le2->setEchoMode(QLineEdit::Password);    //设置正常模式
      le2->setPlaceholderText("密码");
      le2->setStyleSheet("background-color:red");  //设置为红色
      speech =new QTextToSpeech(this);
          //speech->say();
}

Widget::~Widget()
{
    delete ui;
}
void Widget::on_b2()
{
    this->close();
}

void Widget::my_solt()
{
    if(this->le1->text()=="LOL"&&this->le2->text()=="112233")
    {
        qDebug()<<"登陆成功";
        this->close();
    }else
    {
        qDebug()<<"登陆失败";
        this->le2->clear();
    }
}

 

 

 

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值