C++ (Qt)namespace Ui { class MainWindow;} class MainWindow : public QMainWindow{ Q_OBJECTprivate: Ui::MainWindow *ui;};
C++ (Qt)MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this);}MainWindow::~MainWindow(){ delete ui; delete model;}
C++ (Qt)namespace Ui { class MainWindow; class Dialog;} class MainWindow : public QMainWindow{ Q_OBJECTprivate: Ui::MainWindow *ui; Ui::Dialog *uid;};
C++ (Qt)MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), uid(new Ui::Dialog){ ui->setupUi(this); uid->setupUi(this); // ?}MainWindow::~MainWindow(){ delete ui; delete uid; delete model;}
C++ (Qt)#ifndef UI_PHONES_H#define UI_PHONES_H #include <QtCore/QVariant>#include <QtGui/QAction>#include <QtGui/QApplication>#include <QtGui/QButtonGroup>#include <QtGui/QDialog>#include <QtGui/QDialogButtonBox>#include <QtGui/QHeaderView> QT_BEGIN_NAMESPACE class Ui_Dialog{public: QDialogButtonBox *buttonBox; void setupUi(QDialog *Dialog) { if (Dialog->objectName().isEmpty()) Dialog->setObjectName(QString::fromUtf8("Dialog")); Dialog->resize(490, 362); buttonBox = new QDialogButtonBox(Dialog); buttonBox->setObjectName(QString::fromUtf8("buttonBox")); buttonBox->setGeometry(QRect(350, 20, 81, 241)); buttonBox->setOrientation(Qt::Vertical); buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); retranslateUi(Dialog); QObject::connect(buttonBox, SIGNAL(accepted()), Dialog, SLOT(accept())); QObject::connect(buttonBox, SIGNAL(rejected()), Dialog, SLOT(reject())); QMetaObject::connectSlotsByName(Dialog); } // setupUi void retranslateUi(QDialog *Dialog) { Dialog->setWindowTitle(QApplication::translate("Dialog", "Dialog", 0, QApplication::UnicodeUTF8)); } // retranslateUi }; namespace Ui { class Dialog: public Ui_Dialog {};} // namespace Ui QT_END_NAMESPACE #endif // UI_PHONES_H
C++ (Qt)void MainWindow::on_pushButtonPhones_clicked(){ Ui::Dialog uiPhones; QDialog *phonesDialog = new QDialog; uiPhones.setupUi(phonesDialog); phonesDialog->show();}
C++ (Qt)void MainWindow::on_pushButtonPhones_clicked(){ Ui::Dialog uiPhones; QDialog *phonesDialog = new QDialog(this); uiPhones.setupUi(phonesDialog); phonesDialog->exec(); delete phonesDialog;}