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();
}
相关推荐
老秦包你会4 小时前
Linux第十课---------Linux信号
linux
是真的小外套4 小时前
2023年软考中级信息安全工程师|选择题考点+5道案例分析真题解析(含答案)
java·服务器·网络
速捷工控 PLC触摸屏还原程序5 小时前
S7-200 SMART程序上传提示密码?维修、改造和换机怎么选处理路径?
运维·服务器
鬼手点金5 小时前
Harness 工程:模型之外的竞争力
服务器·人工智能·深度学习·机器学习·bug
LMT流氓兔5 小时前
第四单元——第17课:让回答边生成、边显示
服务器·数据库·人工智能·python·oracle·langchain
北风toto5 小时前
Linux 服务器如何判断 CPU 是否支持 x86-64-v2 指令集
java·linux·服务器
程序员-Benothing5 小时前
Linux抓包分析教程:tcpdump、Wireshark、tshark实战
linux·运维·服务器
QMCY_jason5 小时前
ubuntu x86_64架构的编译 aarch64架构的程序
linux·运维·ubuntu
拂拉氏6 小时前
【知识讲解】 Linux进程间通信之管道与共享内存
linux·进程间通信
其实防守也摸鱼6 小时前
Linux文本处理命令理论学习
linux·服务器·前端·数据库·sql·学习·安全