Details
-
Bug
-
Resolution: Out of scope
-
P4: Low
-
4.5.3
-
None
-
Linux openSUSE 11.2
Description
Calling QTranslator.load() on a QTranslator object that is already installed in the application makes QApplication.setLayoutDirection() useless.
application.installTranslator(&translator); translator.load("somefile"); application.setLayoutDirection(Qt::RightToLeft);// This will NOT change the direction of the application
Note: QApplication.isRightToLeft() returns true but application is displayed left to right
To workaround this bug you have to remove the QTranslator from the application before loading the translation file then reinstall the QTranslator.
Example workaround:
application.removeTranslator(&translator);
translator.load("somefile");
application.installTranslator(&translator);
The following app should be RTL but it is displayed LTR
#include <QApplication> #include <QDialog> #include <QHBoxLayout> #include <QLabel> #include <QTranslator> int main(int argc, char **argv) { QApplication app(argc,argv); QDialog dialog; QHBoxLayout layout; QLabel label1(" 1 "); QLabel label2(" 2 "); layout.addWidget(&label1); layout.addWidget(&label2); dialog.setLayout(&layout); QTranslator translator; app.installTranslator(&translator); // The following line causes the bug translator.load("somefile"); // The following will NOT change the direction of the application app.setLayoutDirection(Qt::RightToLeft); dialog.show(); return app.exec(); }