窗口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;
本文介绍了一个使用Qt实现的简单窗口切换示例。示例中包括两个窗口:Widget和Form。Widget作为主窗口,通过信号与槽机制连接按钮点击事件到Form窗口的显示,并在Form窗口内的按钮被点击时返回到Widget窗口。
278

被折叠的 条评论
为什么被折叠?



