[PyQt] QTranslator and QFileDialog problems
eugen.koller at gmail.com
Fri Jun 25 13:51:00 BST 2010
I have used static linking to qt_de only in my example. In my real
code I am using the systems locale and I have the same problem with
other languages as well. All Qt translations are working fine except
when using any of 'getOpenFileName', 'getSaveFileName' and
'getExistingDirectory' with QFileDialog which are always displayed in
English. With 'DontUseNativeDialog' option enabled they are translated
correctly. I can live with this problem if this is happening only our
my development machines.
2010/6/25 Mark Summerfield <list at qtrac.plus.com>:
> 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",
>> dlg1 = QFileDialog(None, "Dialog 1", ".", "All files (*.*)")
>> dlg2 = QFileDialog.getOpenFileName(None, "Dialog 2", ".", "All files
>> (*.*)") dlg3 = QMessageBox.question(None,
>> "Dialog 3",
> 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:
> Mark Summerfield, Qtrac Ltd, www.qtrac.eu
> C++, Python, Qt, PyQt - training and consultancy
> "Advanced Qt Programming" - ISBN 0321635906
> I ordered a Dell netbook with Ubuntu...
> I got no OS, no apology, no solution, & no refund (so far)
There are 10 kinds of people.
Those who understand binary notation, and those who do not.
More information about the PyQt