开发者

Why didn't the dialog in the class execute?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜