Translation of standard buttons in MessageDialog ?
Unsolved
QML and Qt Quick
-
Here is lovely and simple code to make a MessageDialog. I have a few questions:
- I cannot find any mention of how one causes the standard buttons (e.g. "Yes") to be translated into another language (e.g. "Ja" in German).
- I find examples stating that there is a property that one can set "modal: true" - but this doesn't seem to exist. Does it mean the example I've seen was an earlier version of MessageDialog, and the newer version has lost features?
- Of lesser importance, but of interest: in QML it seems easy to specify fonts, colors, radios of rectangles - but I can't seem to get any of that stuff to work to make the MessageDialog look nicer. What's up with that?
If I want these things, must I abandon MessageDialog and do it all myself from scratch?
Thanks for any hints you can give me!
MessageDialog { id: notificationPopup title: qsTr("Please Confirm") text: qsTr("Click 'Yes' to switch to the new language.") informativeText: qsTr("When you select 'Yes' the program will close.") detailedText: qsTr("After the program closes, just re-start it, and the new language will be shown.") buttons: Dialog.Yes | Dialog.Cancel onButtonClicked: function(button, role) { switch (button) { case MessageDialog.Yes: GUISettings.curLangIndex = langSelect.currentIndex Qt.quit(); break; case MessageDialog.Cancel: // restore combo selection - this makes ComboBox redraw GUISettings.curLangIndexChanged(); break; } } }
-
Answering my own question -- well, I switched from using "MessageDialog" to instead using "Dialog" then used a footer of type DialogButtonBox, and finally could make translation happen by using "onOpened" -- below is partial of my Dialog...
footer: DialogButtonBox { id: buttons font.pointSize: medButTextSize font.bold: stnButtonTextBold alignment: Qt.AlignRight | Qt.AlignBottom buttonLayout: Qt.WinLayout // puts 'Cancel' button on the right standardButtons: Dialog.Cancel | Dialog.Yes } onOpened: { buttons.standardButton(Dialog.Yes).text = qsTr("Yes"); buttons.standardButton(Dialog.Cancel).text = qsTr("Cancel"); }
1/2