main.cpp
==========
#include <QtGui/QApplication>
#include "dialog.h"
int main(int argc, char *argv[])
{
Dialog w;
w.show();
return a.exec();
}
########################################
dialog.cpp
============
#include <QtGui>
#include "dialog.h"
#include "x1dialog.h"
{
setupUi(this);
connect(pushButton, SIGNAL(clicked()), this, SLOT(on_pushButton_clicked()));
}
void Dialog::on_pushButton_clicked()
{
Dialog::close();
x1Dialog dialog(this);
dialog.exec();
}
dialog.h
===========
#ifndef DIALOG_H
#define DIALOG_H
#include <QtGui/QDialog>
#include "ui_dialog.h"
class Dialog
: public QDialog,
public Ui
::Dialog{
Q_OBJECT
public:
public slots:
void on_pushButton_clicked();
};
#endif
dialog.ui
============
<ui version="4.0" >
<class>Dialog</class>
<widget class="QDialog" name="Dialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>Dialog</string>
</property>
<widget class="QPushButton" name="pushButton" >
<property name="geometry" >
<rect>
<x>60</x>
<y>100</y>
<width>75</width>
<height>28</height>
</rect>
</property>
<property name="text" >
<string>PushButton</string>
</property>
</widget>
<widget class="QLabel" name="label" >
<property name="geometry" >
<rect>
<x>170</x>
<y>70</y>
<width>161</width>
<height>131</height>
</rect>
</property>
<property name="text" >
<string>This is the 1st dialog</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
###############################################################################
x1dialog.cpp
===============
#include <QtGui>
#include "dialog.h"
#include "x1dialog.h"
x1Dialog
::x1Dialog(QWidget *parent
){
setupUi(this);
connect(pushButton, SIGNAL(clicked()), this, SLOT(on_pushButton_clicked()));
}
void x1Dialog::on_pushButton_clicked()
{
x1Dialog::close();
Dialog dialog(this);
dialog.exec();
}
x1dialog.h
=============
#ifndef X1DIALOG_H
#define X1DIALOG_H
#include <QtGui/QDialog>
#include "ui_x1dialog.h"
class x1Dialog
: public QDialog,
public Ui
::x1Dialog{
Q_OBJECT
public:
public slots:
void on_pushButton_clicked();
};
#endif
x1dialog.ui
==============
<ui version="4.0" >
<class>x1Dialog</class>
<widget class="QDialog" name="x1Dialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>x1Dialog</string>
</property>
<widget class="QPushButton" name="pushButton" >
<property name="geometry" >
<rect>
<x>60</x>
<y>100</y>
<width>75</width>
<height>28</height>
</rect>
</property>
<property name="text" >
<string>PushButton</string>
</property>
</widget>
<widget class="QLabel" name="label" >
<property name="geometry" >
<rect>
<x>170</x>
<y>70</y>
<width>161</width>
<height>131</height>
</rect>
</property>
<property name="text" >
<string>This is the 2nd dialog</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
main.cpp
==========
#include <QtGui/QApplication>
#include "dialog.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Dialog w;
w.show();
return a.exec();
}
########################################
dialog.cpp
============
#include <QtGui>
#include "dialog.h"
#include "x1dialog.h"
Dialog::Dialog(QWidget *parent)
: QDialog(parent)
{
setupUi(this);
connect(pushButton, SIGNAL(clicked()), this, SLOT(on_pushButton_clicked()));
}
void Dialog::on_pushButton_clicked()
{
Dialog::close();
x1Dialog dialog(this);
dialog.exec();
}
dialog.h
===========
#ifndef DIALOG_H
#define DIALOG_H
#include <QtGui/QDialog>
#include "ui_dialog.h"
class Dialog : public QDialog, public Ui::Dialog
{
Q_OBJECT
public:
Dialog(QWidget *parent = 0);
public slots:
void on_pushButton_clicked();
};
#endif
dialog.ui
============
<ui version="4.0" >
<class>Dialog</class>
<widget class="QDialog" name="Dialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>Dialog</string>
</property>
<widget class="QPushButton" name="pushButton" >
<property name="geometry" >
<rect>
<x>60</x>
<y>100</y>
<width>75</width>
<height>28</height>
</rect>
</property>
<property name="text" >
<string>PushButton</string>
</property>
</widget>
<widget class="QLabel" name="label" >
<property name="geometry" >
<rect>
<x>170</x>
<y>70</y>
<width>161</width>
<height>131</height>
</rect>
</property>
<property name="text" >
<string>This is the 1st dialog</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
###############################################################################
x1dialog.cpp
===============
#include <QtGui>
#include "dialog.h"
#include "x1dialog.h"
x1Dialog::x1Dialog(QWidget *parent)
: QDialog(parent)
{
setupUi(this);
connect(pushButton, SIGNAL(clicked()), this, SLOT(on_pushButton_clicked()));
}
void x1Dialog::on_pushButton_clicked()
{
x1Dialog::close();
Dialog dialog(this);
dialog.exec();
}
x1dialog.h
=============
#ifndef X1DIALOG_H
#define X1DIALOG_H
#include <QtGui/QDialog>
#include "ui_x1dialog.h"
class x1Dialog : public QDialog, public Ui::x1Dialog
{
Q_OBJECT
public:
x1Dialog(QWidget *parent = 0);
public slots:
void on_pushButton_clicked();
};
#endif
x1dialog.ui
==============
<ui version="4.0" >
<class>x1Dialog</class>
<widget class="QDialog" name="x1Dialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>x1Dialog</string>
</property>
<widget class="QPushButton" name="pushButton" >
<property name="geometry" >
<rect>
<x>60</x>
<y>100</y>
<width>75</width>
<height>28</height>
</rect>
</property>
<property name="text" >
<string>PushButton</string>
</property>
</widget>
<widget class="QLabel" name="label" >
<property name="geometry" >
<rect>
<x>170</x>
<y>70</y>
<width>161</width>
<height>131</height>
</rect>
</property>
<property name="text" >
<string>This is the 2nd dialog</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
To copy to clipboard, switch view to plain text mode
Bookmarks