Results 1 to 5 of 5

Thread: how to use tr() for QMessageBox?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how to use tr() for QMessageBox?

    Hi,

    Qt Code:
    1. QMessageBox messageBox(tr("Info"),
    2. tr("My message translated"),
    3. QMessageBox::Question,
    4. QMessageBox::Yes | QMessageBox::Default,
    5. QMessageBox::Cancel | QMessageBox::Escape, //This makes "Esc" key to Cancel the Dialog
    6. QMessageBox::NoButton,
    7. this);
    8. //Set the translation text of the buttons. Here you need to have a QTranslator installed that will translate the "Yes" and "No" texts:
    9. messageBox.setButtonText(QMessageBox::Yes,tr("Yes"));
    10. messageBox.setButtonText(QMessageBox::Cancel,tr("Cancel"));
    To copy to clipboard, switch view to plain text mode 
    Òscar Llarch i Galán

  2. The following user says thank you to ^NyAw^ for this useful post:

    gfunk (20th November 2007)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.