6月17号

登录界面头文件:

#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();

signals:
    void my_jump();

private slots:
    void on_pushButton_clicked();

private:
    Ui::Widget *ui;
};
#endif // WIDGET_H

登录界面源文件:

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

static QString rightAccount = "admin";
static QString rightPasswd = "123456";
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    this->setWindowFlag(Qt::FramelessWindowHint);
    this->setAttribute(Qt::WA_TranslucentBackground);
}

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


void Widget::on_pushButton_clicked()
{
    QString account = ui->lineEdit->text();
    QString passwd = ui->lineEdit_2->text();
    if(account.compare(rightAccount) == 0 && passwd.compare(rightPasswd) == 0){
        this->close();
        emit my_jump();
    }else{
        ui->lineEdit->clear();
        ui->lineEdit_2->clear();
    }
}

第二界面头文件:

#ifndef SECOND_H
#define SECOND_H

#include <QWidget>

namespace Ui {
class second;
}

class second : public QWidget
{
    Q_OBJECT

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

public slots:
    void jump_solt();

private:
    Ui::second *ui;
};

#endif // SECOND_H

第二界面源文件:

#include "second.h"
#include "ui_second.h"

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

void second::jump_solt(){
    this->show();
}
second::~second()
{
    delete ui;
}

主函数文件:

#include "widget.h"
#include "second.h"

#include <QApplication>

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

    QObject::connect(&w, &Widget::my_jump, &s, &second::jump_solt);
    return a.exec();
}

相关推荐

  1. 617

    2024-06-18 08:48:05       36 阅读
  2. 1210总结

    2024-06-18 08:48:05       60 阅读
  3. 假期作业 26

    2024-06-18 08:48:05       46 阅读
  4. 寒假作业26

    2024-06-18 08:48:05       52 阅读

最近更新

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

    2024-06-18 08:48:05       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-06-18 08:48:05       100 阅读
  3. 在Django里面运行非项目文件

    2024-06-18 08:48:05       82 阅读
  4. Python语言-面向对象

    2024-06-18 08:48:05       91 阅读

热门阅读

  1. Azure数据分析入门-发现数据分析

    2024-06-18 08:48:05       28 阅读
  2. Mac电脑安装配置NVM

    2024-06-18 08:48:05       36 阅读
  3. 架构设计 - 本地热点缓存

    2024-06-18 08:48:05       26 阅读
  4. 热门开源项目推荐

    2024-06-18 08:48:05       28 阅读
  5. 解析网络空间的安全威胁与应对

    2024-06-18 08:48:05       29 阅读
  6. 11、Spring之Bean生命周期~依赖注入(2)

    2024-06-18 08:48:05       22 阅读
  7. Go微服务: 悲观锁

    2024-06-18 08:48:05       37 阅读
  8. websocket nignx 配置

    2024-06-18 08:48:05       25 阅读
  9. 力扣-2379. 得到 K 个黑块的最少涂色次数

    2024-06-18 08:48:05       33 阅读
  10. 【快速定位生产问题】

    2024-06-18 08:48:05       32 阅读