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();
}
相关推荐
q***748几秒前
在Linux系统上使用nmcli命令配置各种网络(有线、无线、vlan、vxlan、路由、网桥等)
linux·服务器·网络
我也要当昏君26 分钟前
4.1.8 【2022 统考真题】
运维·服务器·网络
2301_8075832331 分钟前
zabbix监控ES集群健康状态并触发钉钉告警
linux·zabbix
Elias不吃糖39 分钟前
eventfd 初认识Reactor/多线程服务器的关键唤醒机制
linux·服务器·c++·学习
磊〜39 分钟前
Linux 服务器安装 dstat 监控插件
linux·运维·服务器
无聊的小坏坏41 分钟前
从 OneThreadOneLoop 线程池到进程池:高性能 Reactor 服务器的演进
服务器·网络·一个进程一个事件循环
Csxyzj42 分钟前
nginx
服务器·nginx
二进制coder44 分钟前
服务器BMC开发视角:解析CPU管理的两大核心接口PECI与APML
运维·服务器·网络
大连滚呢王1 小时前
Linux(麒麟)服务器离线安装单机Milvus向量库
linux·python·milvus·银河麒麟·milvus_cli
嗝屁小孩纸1 小时前
免费测评RPC分布式博客平台(仅用云服务器支持高性能)
服务器·分布式·rpc