QT ui多界面跳转

mainwindow.h

#include "test1.h"
#include "test2.h"

public:
    void pB_test1();
    void pB_test2();

mainwindow.cpp

……
ui->setupUi(this);

connect(ui->Pb_Test1, &QPushButton::clicked, [this](){
    
    

   Test1* p1 = new Test1();
   p1->show();
   this->close();
});

connect(ui->Pb_Test2, &QPushButton::clicked, [this](){
    
    

   Test2* p2 = new Test2();
   p2 ->show();
   this->close();
});

test1.h

#include "mainwindow.h"

public:
    void Pb_back1();

test1.cpp

ui->setupUi(this);

connect(ui->pB_back1, &QPushButton::clicked, [this]{
    
    
    MainWindow* pMain = new MainWindow;
    pMain->show();
    this->close();
});

test2.h(和test1一样)

窗口互换源码

猜你喜欢

转载自blog.csdn.net/qq_43641765/article/details/112752621
今日推荐