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();
}
相关推荐
PC2005-cloud1 小时前
博文已索引但不展示:一次 Bing SEO 问题排查记录
服务器·人工智能
沸速存储1 小时前
整机瓶颈判断思路,自上而下定位卡顿根源
运维·服务器·电脑·内容运营
乌萨奇也要立志学C++1 小时前
【Linux】网络基础 从零理解网络通信:局域网、跨网传输与 Socket 预备知识
linux·服务器·网络
RisunJan3 小时前
Linux命令-slabtop(实时显示内核 slab 缓存信息)
linux
2601_965798475 小时前
Is Hygia Good for Maid & Janitorial Sites? Technical Audit
服务器·网络·数据库
蚰蜒螟6 小时前
从内核源码看Linux启动:chroot、execve与MS_MOVE的协奏曲
linux·服务器·网络
酷可达拉斯6 小时前
自动化运维-ansible配置文件与主机清单
linux·运维·自动化·ansible
影视飓风TIM6 小时前
Linux下C语言缓冲区原理 + Git版本控制
linux·c语言·git
来者皆善7 小时前
ZYNQ linux上使用 USB CDC ACM
linux·运维·服务器
缓慢更新8 小时前
企业档案管理系统迁移实录:从文件服务器到智能检索引擎
运维·服务器