#includeQDialog* dialog = new QDialog(parent); dialog->setWindowTitle("Hello World"); dialog->show();
ui->setupUi(this); QPushButton* okButton = ui->buttonBox->button(QDialogButtonBox::Ok); QPushButton* cancelButton = ui->buttonBox->button(QDialogButtonBox::Cancel); connect(okButton, SIGNAL(clicked()), this, SLOT(accept())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));This example shows how to add buttons to a QDialog using Qt Designer. The Ok and Cancel buttons are added using the buttonBox widget, and are connected to the accept() and reject() slots to close the dialog. Package library: Qt GUI library.