如何在Qt程序实现简单的窗口跳转

来源:互联网 发布:mac电脑网线转接头 编辑:程序博客网 时间:2024/06/06 06:36
 

窗口1 :

Widget
namespace Ui {
    class Widget;
    class Form;
}

构造函数加入:connect(btn1,SIGNAL(clicked()),this,SLOT(open1()));

void Widget::open1()
{
    this->hide();
    w1 = new Form;
    w1->show();
    connect(this->w1->f_ui->pushButton,SIGNAL(clicked()),this,SLOT(Display()));

}

void Widget::Display()
{
    this->show();
     w1->close();
}
窗口2 :

Form
#include "ui_form.h"
public:
 Ui::Form *f_ui;