qtday2(2024/1/9)

#ifndef MYWIDGET_H
#define MYWIDGET_H

#include <QMainWindow>
#include<QDebug>
#include<QIcon>
#include<QPushButton>
#include<QLineEdit>
#include<QLabel>
#include<cstring>
#include<iostream>

class MyWidget : public QMainWindow
{
    Q_OBJECT

public:
    MyWidget(QWidget *parent = 0);
    ~MyWidget();
public slots:
    void log_slot();
    void close_slot();
private:
    QPushButton *btn1;
    QPushButton *btn2;
    QLineEdit *edt1;
    QLineEdit *edt2;
};

#endif // MYWIDGET_H

#include "mywidget.h"

MyWidget::MyWidget(QWidget *parent)
    : QMainWindow(parent)
{
    //设置界面固定大小
    this->resize(1728,972);
    this->setFixedSize(1728,972);
    this->setWindowIcon(QIcon(":/pic/qq1.png"));
    this->setWindowTitle("WeGame");
    this->setWindowFlag(Qt::FramelessWindowHint);

    //设定主界面背景
    QLabel *lab1=new QLabel(this);
    lab1->resize(1728,972);
    lab1->setPixmap(QPixmap(":/pic/hb.jpg"));
    lab1->setScaledContents(true);

    //设置游戏图标
    QLabel *lab2=new QLabel(this);
    lab2->resize(400,300);
    lab2->move(664,130);
    lab2->setPixmap(QPixmap(":/pic/1.2.png"));
    lab2->setScaledContents(true);

    //设置qq图标
    QLabel *lab3=new QLabel(this);
    lab3->resize(70,70);
    lab3->move(800,450);
    lab3->setPixmap(QPixmap(":/pic/qq.png"));
    lab3->setScaledContents(true);

    //设置微信图标
    QLabel *lab4=new QLabel(this);
    lab4->resize(70,70);
    lab4->move(928,450);
    lab4->setPixmap(QPixmap(":/pic/wx.png"));
    lab4->setScaledContents(true);

    //账号编辑
    edt1=new QLineEdit(this);
    edt1->resize(390,65);
    edt1->move(710,524);
    edt1->setPlaceholderText("请输入账号:");

    //密码设置
    edt2=new QLineEdit(this);
    edt2->resize(390,65);
    edt2->move(710,610);
    edt2->setPlaceholderText("请输入密码:");
    edt2->setEchoMode(QLineEdit::Password);

    //复选框保存密码
    QLabel *edit3=new QLabel("保存密码",this);
    edit3->move(710,690);
    edit3->resize(140,40);

    //复选框自动登录
    QLabel *edit4=new QLabel("自动登录",this);
    edit4->move(870,690);
    edit4->resize(140,40);

    //二维码
    QLabel *edt3=new QLabel(this);
    edt3->setPixmap(QPixmap(":/pic/ew.png"));
    edt3->move(1030,690);
    edt3->resize(50,40);
    edt3->setScaledContents(true);

    //快速安全登录按钮
    btn1=new QPushButton("快速安全登录",this);
    btn1->resize(390,65);
    btn1->move(710,760);
    btn1->setStyleSheet("background-color:rgb(255,102,40)");

    //右上角的x
    btn2=new QPushButton("×",this);
    btn2->resize(40,40);
    btn2->move(1670,0);

    //右上角的-
    QPushButton *btn3=new QPushButton("-",this);
    btn3->resize(40,40);
    btn3->move(1630,0);

    //使用qt4将右上角x设置关闭触发
    connect(btn2,SIGNAL(clicked()),this,SLOT(close_slot()));

    //使用qt5将快速登录按钮设置触发事件
    connect(btn1,&QPushButton::clicked,this,&MyWidget::log_slot);
}

void MyWidget::close_slot()
{
    this->close();
}

void MyWidget::log_slot(){
    //比较账号和密码
    if(QString::compare("admin",edt1->text())==0 && QString::compare("123456",edt2->text())==0){
        qDebug()<<"登录成功";
        this->close();
    }else {
        edt2->clear();
        qDebug()<<"登录失败";
    }
}

MyWidget::~MyWidget()
{

}

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值