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();
}
相关推荐
CCPC不拿奖不改名6 小时前
虚拟机基础:在VMware WorkStation上安装Linux为容器化部署打基础
linux·运维·服务器·人工智能·milvus·知识库搭建·容器化部署
山峰哥6 小时前
数据库调优实战:索引策略与查询优化案例解析
服务器·数据库·sql·性能优化·编辑器
一只自律的鸡8 小时前
【Linux系统编程】文件IO 函数篇
linux·linux系统编程
dinga198510269 小时前
linux上redis升级
linux·运维·redis
hzc09876543219 小时前
Linux系统下安装配置 Nginx 超详细图文教程_linux安装nginx
linux·服务器·nginx
jjjxxxhhh1239 小时前
【加密】-AES与对称加密
java·服务器·网络
RisunJan10 小时前
Linux命令-ltrace(用来跟踪进程调用库函数的情况)
linux·运维·服务器
阿乐艾官10 小时前
【 LVM 创建逻辑卷】
linux
予枫的编程笔记10 小时前
【Linux高级篇】搞定文件句柄+TIME_WAIT,Linux内核初步调优实操指南
linux·linux运维·ulimit·time_wait·sysctl.conf·内核调优·服务器优化
c***032310 小时前
linux centos8 安装redis 卸载redis
linux·运维·redis