Disable OK button in ButtonBox (in mobile development)
-
I have a typical dialog window that is invoked from main window using a button via exec() call.
This window contain "buttonBox" that translates to standard "soft buttons" Ok and Cancel.
I want application to disable "OK" button till correct value is received from user in dialog.In dialog constructor I have:
@
ui->setupUi(this);
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
@but it does not affect the actual behaviour, the button is available and dialog is closed when it's pressed.
How I can disable/reenable a standard button in mobile app dialog?
[EDIT: code formatting, please use @-Tags, Volker]
-
This must be done in the show event. The buttons are enabled after the constructor :-( I had some similar problems and solved it by a flag (Initialised) and done it once in the show event.
@
myDialog::showEvent()
{
if(!initialized)
{
initialized = true;
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
}
}
@