4月26日

#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
 
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
 
 
    this->setWindowTitle("QQ");                                     //title
    this->setWindowIcon(QIcon(":/icon/login.png"));                 //icon
    this->setFixedSize(800, 600);                                   //设置固定格式
 
 
    button_loin = new QPushButton(this);
    button_loin->setText("登录");
    button_loin->move(230, 500);
    button_exit = new QPushButton(this);
    button_exit->setText("退出");
    button_exit->move(430, 500);
 
 
 
    label_loin = new QLabel(this);
    label_loin->resize(50, 50);
    label_loin->setScaledContents(true);                            //设置图片自适应标签大小
    label_loin->setPixmap(QPixmap(":/icon/userName.jpg"));
    label_loin->move(200, 300);
 
 
 
    label_password = new QLabel(this);
    label_password->resize(50, 50);
    label_password->setScaledContents(true);                //设置图片自适应标签大小
    label_password->setPixmap(QPixmap(":/icon/passwd.jpg"));
    label_password->move(200, 400);
 
 
 
    label_logo = new QLabel(this);
    label_logo->resize(800, 200);
    label_logo->setScaledContents(true);                //设置图片自适应标签大小
    label_logo->setPixmap(QPixmap(":/icon/logo.png"));
 
 
 
 
    line_user = new QLineEdit(this);
    line_user->move(270, 300);
    line_user->setPlaceholderText("账户");                //设置占文文本
 
 
 
 
    line_password = new QLineEdit(this);
    line_password->move(270, 400);
    line_password->setPlaceholderText("密码");                //设置占文文本
    line_password->setEchoMode(QLineEdit::Password);         //设置密文模式
 
 
    //qt 4.0版本的连接, 即使信号函数和槽函数写错了, 也不报错, 只是运行时没有效果
 
    //将按钮loin的clicked信号, 连接到自定义的槽函数里, 处理相关逻辑
    //connect(this->button_exit, SIGNAL(clicked()), this, SLOT(my_solt()));
    //connect(this->button_loin, SIGNAL(clicked()), this, SLOT(loin_solt()));
 
    speech = new QTextToSpeech(this);
 
 
    //qt 5.0版本的连接,
    //connect(this->button_exit, &QPushButton::clicked, this, &Widget::my_solt1);
    //connect(this->button_loin, &QPushButton::clicked, this, &Widget::my_solt2);
    connect(button_exit, &QPushButton::clicked, [&](){
        this->close();
 
    });
 
}
 
Widget::~Widget()
{
    delete ui;
}
 
 
 
/*
 
//自定义的槽函数
void Widget::my_solt()
{
    this->close();
}
 
void Widget::loin_solt()
{
    if (this->line_user->text() == QString("admire") && this->line_password->text() == QString("123456"))
    {
        qDebug() << "登录";
    }
    else
    {
        this->line_password->setText("");
        qDebug() << "失败";
    }
}
 
*/
 
 
 
/*
void Widget::my_solt1()
{
    this->close();
 
}
 
void Widget::my_solt2()
{
    if (this->line_user->text() == QString("admire") && this->line_password->text() == QString("123456"))
    {
        qDebug() << "登录成功";
        speech->say(QString("登录成功"));
    }
    else
    {
        qDebug() << "登陆失败";
    }
}
*/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值