
办公技巧窗口切换(Qt界面切换)
- 办公技巧
- 2023-07-04 10:08:50
- 0
创建新界面类的方法:
右击工程-->add new-->
-->选择相应的窗体类
信号槽函数法
oneform.h
#ifndef ONEFORM_H#define ONEFORM_H#include
oneform.cpp
#include "oneform.h"#include "ui_oneform.h"oneform::oneform(QWidget *parent) : QWidget(parent) , ui(new Ui::oneform){ ui->setupUi(this); connect(ui->pushButton,SIGNAL(clicked(void)),this,SLOT(one_two(void))); win=new twoform; //创建界面2 connect(win,SIGNAL(oneFunc(void)),this,SLOT(oneshow(void))); //接受界面2发送的信号}oneform::~oneform(){ delete ui;}void oneform::one_two(){ win->show(); this->hide();}void oneform::oneshow(){ this->show();}
QT开发交流 赀料君羊:714620761
twoform.h
#ifndef TWOFORM_H#define TWOFORM_H#include
twoform.cpp
#include "twoform.h"#include "ui_twoform.h"twoform::twoform(QWidget *parent) : QWidget(parent), ui(new Ui::twoform){ ui->setupUi(this); connect(ui->pushButton,SIGNAL(clicked(void)),this,SLOT(two_one(void)));}twoform::~twoform(){ delete ui;}void twoform::two_one(){ emit oneFunc(); //发射信号,通知界面1显示---界面1需要接受这个信号 this->hide();}
本文由 京廊文化根据互联网搜索查询后整理发布,旨在分享有价值的内容,本站为非营利性网站,不参与任何商业性质行为,文章如有侵权请联系删除,部分文章如未署名作者来源请联系我们及时备注,感谢您的支持。
本文链接: /bangong/2261.html