Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Translation of standard buttons in MessageDialog ?

Translation of standard buttons in MessageDialog ?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 1 Posters 103 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tullhead
    wrote on 27 Mar 2025, 02:20 last edited by
    #1

    Here is lovely and simple code to make a MessageDialog. I have a few questions:

    1. 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).
    2. 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?
    3. 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;
            }
         }
      }
    
    1 Reply Last reply
    0
    • T Offline
      T Offline
      Tullhead
      wrote on 28 Mar 2025, 20:11 last edited by
      #2

      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 Reply Last reply
      0

      1/2

      27 Mar 2025, 02:20

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved