![](https://img-blog.csdnimg.cn/direct/5e587c6c601d438685810237748b62e8.png)
头文件
form.h
#ifndef FORM_H
#define FORM_H
#include <QWidget>
#include"widget.h"
#include<QPixmap>
namespace Ui {
class Form;
}
class Form : public QWidget
{
Q_OBJECT
public:
explicit Form(QWidget *parent = 0);
~Form();
QPixmap pix;
private slots:
void on_pushButton_clicked();
private:
Ui::Form *ui;
};
#endif // FORM_H
修改的
![](https://img-blog.csdnimg.cn/direct/70494291b36f492f9f6038b1e2517b65.png)
widget.h
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include"form.h"
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
private slots:
void on_pushButton_clicked();
void on_pushButton_2_clicked();
private:
Ui::Widget *ui;
};
#endif // WIDGET_H
修改的
![](https://img-blog.csdnimg.cn/direct/87ade39da4b14bfea3ebbff17a2bf97c.png)
源文件
form.cpp
#include "form.h"
#include "ui_form.h"
Form::Form(QWidget *parent) :
QWidget(parent),
ui(new Ui::Form)
{
ui->setupUi(this);
pix.load(":/new/prefix1/5.jpeg");
ui->label->setPixmap(pix);
ui->label->setScaledContents(true);
}
Form::~Form()
{
delete ui;
}
void Form::on_pushButton_clicked()
{
this->hide();
Widget *w=new Widget();
w->show();
}
修改的
![](https://img-blog.csdnimg.cn/direct/b5954e3fcb9a45c2b9faed2bbd1b536f.png)
widget.cpp
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_pushButton_clicked()
{
if(ui->lineEdit->text()=="123")
{
Form *f1=new Form();
f1->show();
this->hide();
}
}
void Widget::on_pushButton_2_clicked()
{
this->close();
}
修改的
![](https://img-blog.csdnimg.cn/direct/1d1079c009574032b8c555f4b3aa7938.png)
界面文件
form.ui
![](https://img-blog.csdnimg.cn/direct/6dc044e19911476696d9eb19790e182d.png)
widget.ui
![](https://img-blog.csdnimg.cn/direct/b8d17dcd6e644bcda30f1c252ab095b6.png)
资源