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();
}
相关推荐
KKKlucifer3 分钟前
4A 平台如何提升企业账号安全与操作可追溯性
运维·服务器·网络
Jonathan Star13 分钟前
在 Claude Code 中重新加载插件,最常用的是 **`/reload-plugins` 热重载**,也
linux·运维·服务器
SEO-狼术15 分钟前
Secure PDF Delphi Edition
服务器·windows·pdf
A.A呐17 分钟前
【Linux第二十一章】http
linux·运维·http
羊小猪~~17 分钟前
【QT】-- QT操作数据库
数据库·qt·oracle
mhkxbq18 分钟前
山东H3C服务器R4700G5等多型号,哪家售后有保障?
运维·服务器
海域云-罗鹏19 分钟前
企业部署私有化模型,深圳数据中心服务器托管是关键
运维·服务器
恒创科技HK21 分钟前
高防服务器有什么作用?
运维·服务器
王琦031821 分钟前
第七章 命令解释器-shell
linux·运维·服务器
星如雨グッ!(๑•̀ㅂ•́)و✧21 分钟前
Reactor背压
java·服务器·前端