QT 实现窗口的跳转

复制代码
#include <QApplication>
#include <QDebug>
#include <QWidget>
#include <QTextEdit>
#include <QLineEdit>
#include <QPushButton>
#include <QBoxLayout>
#include <QLabel>

class Widget:public QWidget{
    QPushButton* but;
    Widget* other;
public:
    Widget();
    void setother(Widget& w);
    void buttext(const char* text);
    void click();
};

Widget::Widget() : other(NULL)
{
     but = new QPushButton(this);
     QVBoxLayout lay;
     lay.addWidget(this);
     QObject::connect(but, &QPushButton::clicked, this, &Widget::click);
 }

void Widget::setother(Widget& w)
{
    other=&w;
}

void Widget::buttext(const char* text)
{
    but->setText(text);
}

void Widget::click()
{
    this->hide();
    if (other) {
        other->show();
    }
}

int main(int argc,char** argv)
{
    QApplication app(argc,argv);

    Widget w1,w2;
    w1.buttext("w1.but");
    w2.buttext("w2.but");
    w1.setother(w2);
    w2.setother(w1);

    w1.show();

    return app.exec();
}
相关推荐
青禾8373 小时前
Linux 操作系统入门指南:从目录结构到常用命令
linux·运维·服务器
zhengqweasd4 小时前
流量没跑满、带宽空闲,业务依然卡顿
运维·服务器·网络
闖644 小时前
入门Linux操作系统|零基础吃透原理、目录、权限、常用命令
linux
bruk_spp5 小时前
linux pinctrl
linux
M哥支付5 小时前
高频交易优选方案:银联快捷支付通道
服务器·网络·其他·微信·金融
稳联技术老娜6 小时前
伺服内嵌EtherNet IP方案:嵌入式小板SPI通讯固件Demo程序适配改造
运维·服务器·网络
_林枭_6 小时前
ZW3D二次开发_原生表单_如何设置表单左上角图标
qt·zw3d
en.en..6 小时前
Linux系统编程:fcntl 与 ioctl
linux·运维·服务器
自动化监测Learner7 小时前
Navicat Premium 17 中文版安装教程(2026最新版)
java·linux·数据库
会周易的程序员8 小时前
5Draft(五帝)测试报告
服务器·c++·分布式·raft·共识算法·共识·算力服务器