Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
connect(ui->addButton , SIGNAL(clicked()) , this , SLOT(addItem()));
connect(ui->editButton , SIGNAL(clicked()) , this , SLOT(editItem()));
connect(ui->deleteButton , SIGNAL(clicked()) , this , SLOT(deleteItem()));
}
void Dialog::addItem()
{
EditDialog dlg(this);
dlg.show();
if(dlg.exec() == EditDialog::Accepted)
{
ui->list->addItem(dlg.name() + "--" + dlg.number());
}
}
That a class Dialog to Add Items. When I run the program and click the Button to execute the Dialog it doesn't do anything so What is the solution?
You need to use QDialog::Accepted
If you look at the docs for QDialog::exec
, you will see that it returns a value from the QDialog::DialogCode
enum - the values for which are QDialog::Accepted
and QDialog::Rejected
.