class Ui_enter{public: QLineEdit *db_name; QLineEdit *db_user; QLineEdit *db_pass; QPushButton *bp; QFrame *line; QFrame *line_2; QFrame *line_3; void setupUi(QWidget *enter) { if (enter->objectName().isEmpty()) enter->setObjectName(QString::fromUtf8("enter")); enter->resize(400, 200); enter->setCursor(QCursor(Qt::PointingHandCursor)); db_name = new QLineEdit(enter); db_name->setObjectName(QString::fromUtf8("db_name")); db_name->setGeometry(QRect(30, 20, 113, 20)); db_name->setAutoFillBackground(false); db_user = new QLineEdit(enter); db_user->setObjectName(QString::fromUtf8("db_user")); db_user->setGeometry(QRect(30, 70, 113, 20)); db_pass = new QLineEdit(enter); db_pass->setObjectName(QString::fromUtf8("db_pass")); db_pass->setGeometry(QRect(30, 120, 113, 20)); db_pass->setEchoMode(QLineEdit::Password); bp = new QPushButton(enter); bp->setObjectName(QString::fromUtf8("bp")); bp->setEnabled(true); bp->setGeometry(QRect(294, 162, 101, 31)); line = new QFrame(enter); line->setObjectName(QString::fromUtf8("line")); line->setGeometry(QRect(10, 40, 271, 16)); line->setFrameShape(QFrame::HLine); line->setFrameShadow(QFrame::Sunken); line_2 = new QFrame(enter); line_2->setObjectName(QString::fromUtf8("line_2")); line_2->setGeometry(QRect(10, 90, 271, 16)); line_2->setFrameShape(QFrame::HLine); line_2->setFrameShadow(QFrame::Sunken); line_3 = new QFrame(enter); line_3->setObjectName(QString::fromUtf8("line_3")); line_3->setGeometry(QRect(10, 140, 271, 16)); line_3->setFrameShape(QFrame::HLine); line_3->setFrameShadow(QFrame::Sunken); retranslateUi(enter); QMetaObject::connectSlotsByName(enter); } // setupUi
class Ui_mw{public: QTabWidget *tabWidget; QWidget *tab; QWidget *tab_3; void setupUi(QWidget *mw) { if (mw->objectName().isEmpty()) mw->setObjectName(QString::fromUtf8("mw")); mw->resize(460, 346); tabWidget = new QTabWidget(mw); tabWidget->setObjectName(QString::fromUtf8("tabWidget")); tabWidget->setGeometry(QRect(0, 0, 461, 281)); tab = new QWidget(); tab->setObjectName(QString::fromUtf8("tab")); tabWidget->addTab(tab, QString()); tab_3 = new QWidget(); tab_3->setObjectName(QString::fromUtf8("tab_3")); tabWidget->addTab(tab_3, QString()); retranslateUi(mw); tabWidget->setCurrentIndex(1); QMetaObject::connectSlotsByName(mw); } // setupUi
#ifndef MW_H#define MW_H#include <QDialog>#include "ui_mw.h"class mw: public QDialog, public Ui::mw { Q_OBJECT public: mw(QWidget *parent = 0); private slots: };#endif
#include <QtGui>#include "enter.h"#include "mw.h"enter::enter(QWidget *parent) : QDialog(parent){ setupUi(this); connect(bp, SIGNAL(clicked()),this, SLOT(on_all_lineEdit_textChanged()));}void enter::on_all_lineEdit_textChanged() { mw *dialog = new mw(this); dialog->show(); close(); }
#include <QtGui>#include "mw.h"mw::mw(QWidget *parent) : QDialog(parent){ setupUi(this);}
void EditorWindow::find() { if (!findDialog) { findDialog = new FindDialog(this); connect(findDialog, SIGNAL(findNext()), this, SLOT(findNext())); } findDialog->show(); findDialog->raise(); findDialog->activateWindow(); }
if (!mw) { mw = new QDialog(this); } mw->show(); mw->activateWindow();
client.proTEMPLATE = appTARGET = DEPENDPATH += .INCLUDEPATH += C:/Qt/projects/client/. .# InputHEADERS += enter.h mw.hFORMS += enter.ui mw.uiSOURCES += enter.cpp main.cpp mw.cpp
main.cpp#include <QApplication>#include <QDialog>#include "ui_enter.h"#include "ui_mw.h"int main(int argc, char *argv[]) { QApplication app(argc, argv); Ui::enter ui; QDialog *dialog = new QDialog; ui.setupUi(dialog); dialog->show(); return app.exec(); }
ui_enter.h#ifndef UI_ENTER_H#define UI_ENTER_H#include <QtCore/QVariant>#include <QtGui/QAction>#include <QtGui/QApplication>#include <QtGui/QButtonGroup>#include <QtGui/QFrame>#include <QtGui/QHeaderView>#include <QtGui/QLineEdit>#include <QtGui/QPushButton>#include <QtGui/QWidget>QT_BEGIN_NAMESPACEclass Ui_enter{public: QLineEdit *db_name; QLineEdit *db_user; QLineEdit *db_pass; QPushButton *bp; QFrame *line; QFrame *line_2; QFrame *line_3; void setupUi(QWidget *enter) { if (enter->objectName().isEmpty()) enter->setObjectName(QString::fromUtf8("enter")); enter->resize(400, 200); enter->setCursor(QCursor(Qt::PointingHandCursor)); db_name = new QLineEdit(enter); db_name->setObjectName(QString::fromUtf8("db_name")); db_name->setGeometry(QRect(30, 20, 113, 20)); db_name->setAutoFillBackground(false); db_user = new QLineEdit(enter); db_user->setObjectName(QString::fromUtf8("db_user")); db_user->setGeometry(QRect(30, 70, 113, 20)); db_pass = new QLineEdit(enter); db_pass->setObjectName(QString::fromUtf8("db_pass")); db_pass->setGeometry(QRect(30, 120, 113, 20)); db_pass->setEchoMode(QLineEdit::Password); bp = new QPushButton(enter); bp->setObjectName(QString::fromUtf8("bp")); bp->setEnabled(true); bp->setGeometry(QRect(294, 162, 101, 31)); line = new QFrame(enter); line->setObjectName(QString::fromUtf8("line")); line->setGeometry(QRect(10, 40, 271, 16)); line->setFrameShape(QFrame::HLine); line->setFrameShadow(QFrame::Sunken); line_2 = new QFrame(enter); line_2->setObjectName(QString::fromUtf8("line_2")); line_2->setGeometry(QRect(10, 90, 271, 16)); line_2->setFrameShape(QFrame::HLine); line_2->setFrameShadow(QFrame::Sunken); line_3 = new QFrame(enter); line_3->setObjectName(QString::fromUtf8("line_3")); line_3->setGeometry(QRect(10, 140, 271, 16)); line_3->setFrameShape(QFrame::HLine); line_3->setFrameShadow(QFrame::Sunken); retranslateUi(enter); QMetaObject::connectSlotsByName(enter); } // setupUi void retranslateUi(QWidget *enter) { enter->setWindowTitle(QApplication::translate("enter", "\320\220\320\262\321\202\320\276\321\200\320\270\320\267\320\260\321\206\320\270\321\217", 0, QApplication::UnicodeUTF8)); db_name->setText(QApplication::translate("enter", "\320\222\320\262\320\265\320\264\320\270\321\202\320\265 \320\275\320\260\320\267. \320\221\320\224", 0, QApplication::UnicodeUTF8)); db_user->setText(QApplication::translate("enter", "\320\222\320\262\320\265\320\264\320\270\321\202\320\265 \320\222\320\260\321\210 \320\273\320\276\320\263\320\270\320\275", 0, QApplication::UnicodeUTF8)); db_pass->setText(QApplication::translate("enter", "\320\222\320\262\320\265\320\264\320\270\321\202\320\265 \320\222\320\260\321\210 \320\277\320\260\321\200\320\276\320\273\321\214", 0, QApplication::UnicodeUTF8)); bp->setText(QApplication::translate("enter", "\320\222\320\276\320\271\321\202\320\270 >>", 0, QApplication::UnicodeUTF8)); Q_UNUSED(enter); } // retranslateUi};namespace Ui { class enter: public Ui_enter {};} // namespace UiQT_END_NAMESPACE#endif // UI_ENTER_H
ui_mw.h#ifndef UI_MW_H#define UI_MW_H#include <QtCore/QVariant>#include <QtGui/QAction>#include <QtGui/QApplication>#include <QtGui/QButtonGroup>#include <QtGui/QHeaderView>#include <QtGui/QTabWidget>#include <QtGui/QWidget>QT_BEGIN_NAMESPACEclass Ui_mw{public: QTabWidget *tabWidget; QWidget *tab; QWidget *tab_3; void setupUi(QWidget *mw) { if (mw->objectName().isEmpty()) mw->setObjectName(QString::fromUtf8("mw")); mw->resize(460, 346); tabWidget = new QTabWidget(mw); tabWidget->setObjectName(QString::fromUtf8("tabWidget")); tabWidget->setGeometry(QRect(0, 0, 461, 281)); tab = new QWidget(); tab->setObjectName(QString::fromUtf8("tab")); tabWidget->addTab(tab, QString()); tab_3 = new QWidget(); tab_3->setObjectName(QString::fromUtf8("tab_3")); tabWidget->addTab(tab_3, QString()); retranslateUi(mw); tabWidget->setCurrentIndex(1); QMetaObject::connectSlotsByName(mw); } // setupUi void retranslateUi(QWidget *mw) { mw->setWindowTitle(QApplication::translate("mw", "\320\223\320\273\320\260\320\262\320\275\320\276\320\265 \320\236\320\272\320\275\320\276", 0, QApplication::UnicodeUTF8)); tabWidget->setTabText(tabWidget->indexOf(tab), QApplication::translate("mw", "\320\222\320\262\320\276\320\264 \320\224\320\260\320\275\320\275\320\275\321\213\321\205", 0, QApplication::UnicodeUTF8)); tabWidget->setTabText(tabWidget->indexOf(tab_3), QApplication::translate("mw", "\320\237\321\200\320\276\321\201\320\274\320\276\321\202\321\200 \320\240\320\265\320\267\321\203\320\273\321\214\321\202\320\260\321\202\320\260", 0, QApplication::UnicodeUTF8)); Q_UNUSED(mw); } // retranslateUi};namespace Ui { class mw: public Ui_mw {};} // namespace UiQT_END_NAMESPACE#endif // UI_MW_H
enter.h #ifndef ENTER_H#define ENTER_H#include <QDialog>#include "ui_enter.h"class enter: public QDialog, public Ui::enter { Q_OBJECT public: enter(QWidget *parent = 0); private slots: void on_all_lineEdit_textChanged(); };#endif
mw.h #ifndef MW_H#define MW_H#include <QDialog>#include "ui_mw.h"class mw: public QDialog, public Ui::mw { Q_OBJECT public: mw(QWidget *parent = 0); private slots: };#endif
enter.cpp#include <QtGui>#include "enter.h"#include "mw.h"enter::enter(QWidget *parent) : QDialog(parent){ setupUi(this); connect(bp, SIGNAL(clicked()),this, SLOT(on_all_lineEdit_textChanged()));}void enter::on_all_lineEdit_textChanged() { mw *dialog = new mw(this); dialog->show(); close(); /* if (!mw) { mw = new QDialog(this); //or QMainWindow, or your custom class } mw->show(); mw->activateWindow(); */ }
mw.cpp#include <QtGui>#include "mw.h"mw::mw(QWidget *parent) : QDialog(parent){ setupUi(this);}