QDialog dlg(this);
    QLabel *label = new QLabel("名称:");
    QLineEdit *lineEdit = new QLineEdit();
    label->setBuddy(lineEdit);
    QDialogButtonBox *buttonBox = new QDialogButtonBox(
               QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    connect(buttonBox, SIGNAL(accepted()), &dlg, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), &dlg, SLOT(reject()));
    QGridLayout *gridLayout = new QGridLayout;
    gridLayout->addWidget(label, 0, 0);
    gridLayout->addWidget(lineEdit, 0, 1);
    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(gridLayout);
    mainLayout->addWidget(buttonBox);
    dlg.setLayout(mainLayout);
    dlg.setWindowTitle("对话框名称");
    if(dlg.exec() == QDialog::Accepted)
    {
        QString name = lineEdit->text();
        //,,,
    }