DAY 8.31

#ifndef BUTTON_H
#define BUTTON_H

#include <QWidget>
#include <QPushButton>
#include <QLabel>
#include <QLineEdit>
#include <QString>
#include <QDebug>

QT_BEGIN_NAMESPACE
namespace Ui { class button; }
QT_END_NAMESPACE

class button : public QWidget
{
    Q_OBJECT

signals:
    void my_jump();
public slots:
    void my_slot();
     void my_slot1();
public:
    button(QWidget *parent = nullptr);
    ~button();

private:
    Ui::button *ui;
    QPushButton *btn1;
    QPushButton *btn2;
    QLineEdit * edit1;
    QLineEdit * edit2;
};
#endif // BUTTON_H
#ifndef FORM_H
#define FORM_H

#include <QWidget>

namespace Ui {
class Form;
}

class Form : public QWidget
{
    Q_OBJECT

public:
    explicit Form(QWidget *parent = nullptr);
    ~Form();

public:
    void jump_slot();

private:
    Ui::Form *ui;
};

#endif // FORM_H
#include "button.h"
#include "ui_button.h"

void button::my_slot()
{
    if("admin"==edit1->text()&&edit2->text()=="123456")
    {
        qDebug()<<"登录成功";
        emit my_jump();
        this->close();
    }else {
        qDebug()<<"登录失败";
        edit2->clear();
    }
}

void button::my_slot1()
{
    this->close();
}

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

    this->resize(560,450);
    this->setWindowIcon(QIcon(":/icon/wodepeizhenshi.png"));
    this->setWindowTitle("鹏哥快聊");

    QLabel *lab1 = new QLabel(this);
    lab1->resize(560,200);
    lab1->setPixmap(QPixmap("D:\\嵌入式\\QT\\day1\\icon\\logo.png"));
    lab1->setScaledContents(true);

    QLabel *lab2 = new QLabel(this);
    lab2->resize(40,40);
    lab2->move(80,240);
    lab2->setPixmap(QPixmap("D:\\嵌入式\\QT\\day1\\icon\\userName.jpg"));
    lab2->setScaledContents(true);

    QLabel *lab3 = new QLabel(this);
    lab3->resize(40,40);
    lab3->move(lab2->x(),lab2->y()+80);
    lab3->setPixmap(QPixmap("D:\\嵌入式\\QT\\day1\\icon\\passwd.jpg"));
    lab3->setScaledContents(true);

    edit1 = new QLineEdit(this);
    edit1->resize(280,40);
    edit1->move(lab2->x()+80,lab2->y());
    edit1->setPlaceholderText("QQ号码/手机/邮箱");

    edit2 = new QLineEdit(this);
    edit2->resize(280,40);
    edit2->move(lab3->x()+80,lab3->y());
    edit2->setPlaceholderText("密码");
    edit2->setEchoMode(QLineEdit::Password);

    btn1 = new QPushButton(QIcon("D:\\嵌入式\\QT\\day1\\icon\\login.png"),"登录",this);
    btn1->resize(100,40);
    btn1->move(edit2->x()+100,edit2->y()+80);

    btn2 = new QPushButton(QIcon("D:\\嵌入式\\QT\\day1\\icon\\cancel.png"),"取消",this);
    btn2->resize(100,40);
    btn2->move(btn1->x()+110,btn1->y());

    connect(btn1,&QPushButton::clicked,this,&button::my_slot);
    connect(btn2,SIGNAL(clicked()),this,SLOT(close()));


}

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

#include "form.h"
#include "ui_form.h"

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

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

void Form::jump_slot()
{
    this->show();
}
#include "button.h"
#include "form.h"

#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    button w;
    w.show();

    Form f;
    QObject::connect(&w,&button::my_jump,&f,&Form::jump_slot);
    return a.exec();
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值