4.9

main.c

#include "widget.h"
#include "newwidget.h"

#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Widget w;
    w.show();
    
    Newwidget n;
    
    QObject::connect(&w,&Widget::jump,&n,&Newwidget::showNew);
    QObject::connect(&n,&Newwidget::jump,&w,&Widget::dis);
    
    return a.exec();
}

widget.c

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

#include <QMessageBox>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    this->setWindowFlag(Qt::FramelessWindowHint);
    this->setAttribute(Qt::WA_TranslucentBackground);

    // QMessageBox msg;
    // msg.setText("hello");
    // msg.exec();


}

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

void Widget::on_pushButton_clicked()
{
    if(ui->lineEdit->text() == "1" && ui->lineEdit_2->text() == "1")
    {
        QMessageBox msg(QMessageBox::Information,"信息","登录成功",QMessageBox::Yes);
        int ret = msg.exec();

        if(ret == QMessageBox::Yes)
        {
            this->close();
            emit this->jump();
        }
    }
    else
    {
        QMessageBox msg(QMessageBox::Critical,"错误","账号密码错误,是否重新登录",QMessageBox::Yes| QMessageBox::No);
        int ret = msg.exec();
        if(ret == QMessageBox::Yes)
        {
            ui->lineEdit->clear();
            ui->lineEdit_2->clear();
        }
        else if (ret == QMessageBox::No)
        {
            this->close();
        }
    }
}

void Widget::dis()
{
    this->show();
}

widget.h

#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>

QT_BEGIN_NAMESPACE
namespace Ui {
class Widget;
}
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

private slots:
    void on_pushButton_clicked();

public slots:
    void dis();

private:
    Ui::Widget *ui;

signals:
    void jump();
};
#endif // WIDGET_H

newwidget.cpp

#include "newwidget.h"
#include "ui_newwidget.h"
#include <QMessageBox>

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



}

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

void Newwidget::showNew()
{
    this->show();
}

void Newwidget::on_pushButton_clicked()
{
    QMessageBox msg(QMessageBox::Information,"信息","你是否确定要推出登录",QMessageBox::Yes|QMessageBox::No);
    int ret = msg.exec();
    if(ret == QMessageBox::Yes)
    {
        this->close();
    }
    else if (ret == QMessageBox::No)
    {
        this->close();
        emit this->jump();
    }
}

newwidget.h

#ifndef NEWWIDGET_H
#define NEWWIDGET_H

#include <QWidget>

namespace Ui {
class Newwidget;
}

class Newwidget : public QWidget
{
    Q_OBJECT

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

signals:
    void jump();

public slots:
    void showNew();

private slots:
    void on_pushButton_clicked();

private:
    Ui::Newwidget *ui;
};

#endif // NEWWIDGET_H

相关推荐

  1. misc<span style='color:red;'>49</span>

    misc49

    2024-04-11 12:06:04      44 阅读
  2. 面试经典150题(47-49)

    2024-04-11 12:06:04       55 阅读
  3. LeetCode49. Group Anagrams

    2024-04-11 12:06:04       143 阅读
  4. 商城数据库(49-52)

    2024-04-11 12:06:04       27 阅读
  5. LeetCode 1193, 45, 48

    2024-04-11 12:06:04       33 阅读
  6. Spring (49)OpenFeign

    2024-04-11 12:06:04       33 阅读
  7. 49. 简单数字加密

    2024-04-11 12:06:04       30 阅读
  8. 从零学算法49

    2024-04-11 12:06:04       58 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-11 12:06:04       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-11 12:06:04       106 阅读
  3. 在Django里面运行非项目文件

    2024-04-11 12:06:04       87 阅读
  4. Python语言-面向对象

    2024-04-11 12:06:04       96 阅读

热门阅读

  1. 使用 IEEE (1735) Verilog 标准机制进行 IP 保护

    2024-04-11 12:06:04       41 阅读
  2. ISBN 正则表达式及代码示例

    2024-04-11 12:06:04       39 阅读
  3. Leetcode-1702-修改后的最大二进制字符串-c++

    2024-04-11 12:06:04       42 阅读
  4. vue监听键盘回车事件的三种方法

    2024-04-11 12:06:04       32 阅读
  5. 学习基于pytorch的VGG图像分类 day3

    2024-04-11 12:06:04       37 阅读
  6. 面试算法-168-LRU 缓存

    2024-04-11 12:06:04       32 阅读
  7. 坚持十天做完Python入门编程100题第三天

    2024-04-11 12:06:04       34 阅读
  8. 设计模式:生活中的命令模式

    2024-04-11 12:06:04       38 阅读
  9. 【免安装的MATLAB--MATLAB online】

    2024-04-11 12:06:04       36 阅读
  10. 数据结构与算法 — 贪心算法

    2024-04-11 12:06:04       40 阅读