how to get the accept signal by clicking Apply button
I create a myDialog inhereted from QDialog,and add an Apply button,as you know,when click Apply button,the slot applyslot() is used and the dialog window should not be closed.
I use myDialog as follows:
Code:
myDialog *mydialog=new myDialog (this);
if(mydialog->exec())
{
......
}
for not used accepted() in applyslot(),so applyslot() does not do,how to let the slot applyslot() do and the window does not close?
Re: how to get the accept signal by clicking Apply button
Do not do anything in the applyslot() that will close the dialog. That is, do not call close(), accept(), reject(), or done() or anything that calls them.
Re: how to get the accept signal by clicking Apply button
Quote:
Originally Posted by
ChrisW67
Do not do anything in the applyslot() that will close the dialog. That is, do not call close(), accept(), reject(), or done() or anything that calls them.
If I do as you said,the result of will be false,because only accept() or done() is called ,it will be true.
Re: how to get the accept signal by clicking Apply button
If you continue with a modal dialog then it has three buttons:
- OK: Press this, pending stuff is done, accept() is called, the dialog closed, and true returned.
- Cancel: Press this, pending stuff is not done, reject() is called, the dialog closed, and false returned.
- Apply: Press this, pending stuff is done, nothing is done that would close the dialog, and exec() does not return.
If you want a non-modal dialog then call show() not exec(). You do not get a boolean return this way so you may need to reconsider how stuff is done.