QT

1号文件头文件onewgt.h

#ifndef ONEWGT_H
#define ONEWGT_H

#include <QWidget>
#include <QMessageBox>
#include <QLineEdit>

QT_BEGIN_NAMESPACE
namespace Ui { class onewgt; }
QT_END_NAMESPACE

class onewgt : public QWidget
{
    Q_OBJECT

public:
    onewgt(QWidget *parent = nullptr);
    ~onewgt();
signals:
    void my_signal();
private slots:
    void on_pushButton_2_clicked();
private slots:
    void on_pushButton_clicked();
private:
    Ui::onewgt *ui;
};
#endif // ONEWGT_H

2号文件头文件twowgt.h

#ifndef TWOWGT_H
#define TWOWGT_H

#include <QWidget>

namespace Ui {
class twowgt;
}

class twowgt : public QWidget
{
    Q_OBJECT

public:
    explicit twowgt(QWidget *parent = nullptr);
    ~twowgt();
public slots:
    void my_slot();
private:
    Ui::twowgt *ui;
};

#endif // TWOWGT_H

man.cpp文件

#include "onewgt.h"
#include "twowgt.h"

#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    onewgt w;
    w.show();
    twowgt x;
    QObject::connect(&w,&onewgt::my_signal,&x,&twowgt::my_slot);
    return a.exec();
}

onewgt.cpp文件

#include "onewgt.h"
#include "ui_onewgt.h"

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

    ui->lineEdit->setPlaceholderText("Username");
    ui->lineEdit_2->setPlaceholderText("Passwd");
}

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

void onewgt::on_pushButton_2_clicked()
{
    close();
}
void onewgt::on_pushButton_clicked()
{
    QString get = ui->lineEdit->text();
    QString getpa = ui->lineEdit_2->text();
    if(get == "admin" && getpa == "123456")
    {
        close();
        emit my_signal();
    }else
    {
        QMessageBox::warning(this, "登录", "登录失败");
        ui->lineEdit->clear();
        ui->lineEdit_2->clear();
    }
}
 

twowgt.cpp文件

#include "twowgt.h"
#include "ui_twowgt.h"

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

void twowgt::my_slot()
{
    this->show();
}

相关推荐

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

    QT

    2024-06-18 22:56:04      31 阅读
  2. <span style='color:red;'>QT</span>

    QT

    2024-06-18 22:56:04      40 阅读
  3. Qt 使用qm文件

    2024-06-18 22:56:04       34 阅读

最近更新

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

    2024-06-18 22:56:04       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-06-18 22:56:04       101 阅读
  3. 在Django里面运行非项目文件

    2024-06-18 22:56:04       82 阅读
  4. Python语言-面向对象

    2024-06-18 22:56:04       91 阅读

热门阅读

  1. ARM处理器的应用场景

    2024-06-18 22:56:04       31 阅读
  2. adb 截屏和录屏命令

    2024-06-18 22:56:04       27 阅读
  3. 数据库设计规范总结

    2024-06-18 22:56:04       28 阅读
  4. ubuntu20.04安装配置openMVG+openMVS

    2024-06-18 22:56:04       24 阅读
  5. PostgreSQL源码分析——CREATE SERVER

    2024-06-18 22:56:04       23 阅读
  6. epoll服务端和客户端示例代码

    2024-06-18 22:56:04       30 阅读
  7. 单例设计模式双重检查的作用

    2024-06-18 22:56:04       25 阅读
  8. MyBatis 自定义映射 ResultMap:一对多映射关系处理

    2024-06-18 22:56:04       31 阅读
  9. 删除名为 `XXXX` 的 conda 环境的命令

    2024-06-18 22:56:04       29 阅读
  10. LVGL:

    LVGL:

    2024-06-18 22:56:04      28 阅读