PDA

View Full Version : QML: set standard ok button of a MessageDialog to disabled state



sheetal_awaji
11th August 2018, 10:10
Below is code snippet I have written in main.qml file.
Basically I have a MessageDialog. Here, when disableOkBtn boolean is true, then I want to set standard ok button to disabled state
****************
MessageDialog {
id: mainDialog
..
..
}

/// Java Script

function showMessageBox(bool disableOkBtn) {
if(disableOkBtn) {
mainDialog.standardButtons = StandardButton.Ok | StandardButton.Cancel;
mainDialog.standardButtons(StandardButton.Ok).enab led = false; //this line does not work , Basically here I want to set standard ok button to disabled state
}
}
************************
Please guide me what should be the correct way instead of below line.
mainDialog.standardButtons(StandardButton.Ok).enab led = false;

Above line of code doesn't work

wysota
20th August 2018, 09:01
MessageDialog does not let you access buttons directly. If you need that functionality, you'll have to reimplement the dialog by yourself.