[PyQt] QTranslator and QFileDialog problems

Mark Summerfield list at qtrac.plus.com
Fri Jun 25 12:35:21 BST 2010


On 2010-06-25, Eugen wrote:
> I have some problems with translations of QFileDialog. In the example
> below "dlg2" appears in English on my Windows XP development machine,
> the rest in German. "dlg1" looks like a Qt custom dialog and "dlg2"
> like the windows standard file dialog but with an old icon theme. On
> other computers I have tested this (Ubuntu, Windows 7 and 2000) all
> dialogs are in german. How can I get more information about what file
> dialog Qt is using here and also what kind of theme is used there?
> 
> import sys
> from PyQt4.QtCore import *
> from PyQt4.QtGui import *
> 
> app = QApplication(sys.argv)
> 
> qtTranslator = QTranslator()
> if qtTranslator.load("qt_de",
>                      
QLibraryInfo.location(QLibraryInfo.TranslationsPath)):
>     app.installTranslator(qtTranslator)
> 
> dlg1 = QFileDialog(None, "Dialog 1", ".", "All files (*.*)")
> dlg1.open()
> dlg2 = QFileDialog.getOpenFileName(None, "Dialog 2", ".", "All files
> (*.*)") dlg3 = QMessageBox.question(None,
>                             "Dialog 3",
>                             "Frage?",
>                             QMessageBox.Yes|QMessageBox.No|
>                             QMessageBox.Cancel)
> 
> sys.exit(app.exec_())

Hi Eugen,

The rule of thumb is that Qt uses the native file dialog where one is
available. As for the English vs. German Qt will respect the machine's
locale unless you override it as you're doing here. So maybe you don't
have the qt_de.qm file on your XP machine?

You can tell Qt not to use native dialogs:

http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qfiledialog.html#Option-
enum


-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
    C++, Python, Qt, PyQt - training and consultancy
        "Advanced Qt Programming" - ISBN 0321635906
            http://www.qtrac.eu/aqpbook.html

                I ordered a Dell netbook with Ubuntu...
       I got no OS, no apology, no solution, & no refund (so far)
               http://www.qtrac.eu/dont-buy-dell.html


More information about the PyQt mailing list