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();
}
相关推荐
Android系统攻城狮1 小时前
Linux FFmpeg深度解析之avcodec_flush_buffers调用流程与实战(十九)
linux·运维·服务器·ffmpeg·车载音视频·ffmpeg音视频进阶
水饺编程2 小时前
第2章:Linux 基础,解压缩【.tar.bz2】压缩包文件
linux·c语言·汇编
Y3815326622 小时前
用 httpx 写 SerpBase 异步客户端:连接池与超时配置
运维·服务器·数据库
Zevalin爱灰灰3 小时前
Linux入门第二部分(ARM裸机篇) 第二章 Cortex-A7 MPCore架构与ARM汇编基础
linux·汇编·arm开发·嵌入式
倔强的石头1063 小时前
【Linux指南】进程通信系列(七):System V 信号量 —— 同步互斥的内核原语
linux·运维·服务器
GeW3 小时前
从"补短板"到"强优势"Linux与数据库认证成为产业跃迁人才支点
linux·数据库
PellyKoo5 小时前
【Ubuntu】GTX 1080 Ti 显卡占用为0但功率高达60W的排查与解决
linux·运维·ubuntu
Fruiticecake6 小时前
epoll 回显服务器是怎么工作的:从 accept 队列到就绪链表,以及它和 select / poll 的区别
linux
captain3766 小时前
MyBatis Plus(1)
java·服务器·mybatis
科创致远6 小时前
ESOP 电子作业指导书 WiFi 网络应用实测报告
运维·服务器·网络