Results 1 to 7 of 7

Thread: QFileDialog/ QMessageBox's Button Translation problem

  1. #1
    Join Date
    May 2007
    Posts
    110
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X

    Default QFileDialog/ QMessageBox's Button Translation problem

    Hi

    We are using Unicode i.e. French Version for our product.
    Everything is translated at runtime like Dialog, messagecontent and other string
    using Qt linguist, QTranslator
    and using qApp->installTranslator(&trans);


    But problem is that I m using QMessageBox & QFileDialog .
    QMessageBox's content translated into french at runtime but its Button's content remains is English like Ok, Cancel

    Samething I m using QFileDialog to open file..

    QString str = QFileDialog(/* argument */);

    Whenver this Qt' dialog open, Its three Button New Folder, Open, Cancel will not translated automatically it show in English.

    Same thing for QFileDialog::getExistingDirectory(/* */);

    Its button Save , Cancel is not translated into French it show in English .



    Is there anything that we r missing.
    If anybody know this issue , kindly give me solution.

    Thanks & regards
    Santosh Kumar Singh

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QFileDialog/ QMessageBox's Button Translation problem

    Use this option:
    Qt Code:
    1. QFileDialog::DontUseNativeDialog
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    May 2007
    Posts
    110
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QFileDialog/ QMessageBox's Button Translation problem

    I want to use this in MacOS

    I want to open as a sheet and all Volumes should thatswhy we have used QFileDialog::ShowDirOnly instead of QFileDialog:ontUseNativeDialog .

    But This show all Button in English like Ok, Save, Cancel, New Folder etc..

    This is Qt's inbuild FileDialog and How we can translate its Button text in French at runtime..


    Thanks

  4. #4
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QFileDialog/ QMessageBox's Button Translation problem

    Quote Originally Posted by santosh.kumar View Post
    This is Qt's inbuild FileDialog and How we can translate its Button text in French at runtime
    You can set, because like all other Qt classes, QFileDialog is also implemented in such a way, so you can use it with different languages. You can not change the language of OS specific native dialog. Thats why I suggested to use option DontUseNativeDialog.
    Every text in QFileDialog is entered using tr(), so use can do translation.

  5. #5
    Join Date
    May 2007
    Posts
    110
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QFileDialog/ QMessageBox's Button Translation problem

    We have used this QFileDialog:ontUseNativeDialog but it will not best suit for out application..because its not look like MacOS's dialog...

    We have to use QFileDialog's getSavefileName, getExistingdirectory, getOpenFileName
    ...Kindly tell me another solution for this so that we can show translated button text at run time in French..

    QFileDialog::getSavefileName( );
    It contains three button - New Folder, Cancel , Save.

    Whenever my app run in French MACOSX all string translated but this button text is not translated....Plz tell me another solution...

  6. #6
    Join Date
    Jul 2009
    Posts
    15
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QFileDialog/ QMessageBox's Button Translation problem

    You have to add Qt's own translation files to your app. (look at http://doc.qtsoftware.com/i18n.html#...e-translations)
    You find the qm-files in $QTDIR/translations.
    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication app(argc, argv);
    4.  
    5. // qt translation for default dialogs (QFileDialog) and so on
    6. QTranslator qtTranslator;
    7. qtTranslator.load("qt_" + QLocale::system().name(),
    8. QLibraryInfo::location(QLibraryInfo::TranslationsPath));
    9. app.installTranslator(&qtTranslator);
    10.  
    11. // your own translation
    12. QTranslator myappTranslator;
    13. myappTranslator.load("myapp_" + QLocale::system().name());
    14. app.installTranslator(&myappTranslator);
    15.  
    16. ...
    17. return app.exec();
    18. }
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    May 2007
    Posts
    110
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QFileDialog/ QMessageBox's Button Translation problem

    Ok nice ...
    We found the Translations path for Default dialog..
    We found qt_fr.qm for franchese translation....

    We are using these code

    qtTranslator.load("qt_" + QLocale::system().name(),
    QLibraryInfo::location(QLibraryInfo::TranslationsP ath));
    It is loading qt_fr.qm file.

    We r using Qt 4.3.4 for Mac OS.
    But whenever we make Exe of our application I think we have to include This Qt's Translation folder in our App's -> Contents->Resources->Translation->qt_fr.qm.

    Or any other solution to include this translation path in our Application's Exe.

Similar Threads

  1. problem about mouse button events
    By vql in forum Qt Programming
    Replies: 1
    Last Post: 29th April 2008, 10:14
  2. Replies: 3
    Last Post: 4th December 2007, 10:04
  3. problem with Tool button n Layout
    By arjunasd in forum Qt Tools
    Replies: 11
    Last Post: 24th July 2007, 21:14
  4. Qfiledialog Problem - (Beginner)
    By kingslee in forum Qt Tools
    Replies: 3
    Last Post: 11th October 2006, 23:00
  5. Push Button problem!!
    By Seema Rao in forum Qt Programming
    Replies: 1
    Last Post: 22nd April 2006, 16:31

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.