September 1, 2011

bijanbina bijanbina
Lab Rat
23 posts

Right To left alignment in Qaction

 

hi i want to translate my software to Persian (Farsi)
*note:farsi is a right to left language!
in menu i use “setLayoutDirection” to make menu right to left but in child of menu text is left To right alignment.

so i want to change to right To left. how can i do this?

10 replies

September 1, 2011

Andre Andre
Robot Herder
6400 posts

I would set the direction for the whole application in one go: QApplication::setLayoutDirection. That should take care of the issue.

September 2, 2011

bijanbina bijanbina
Lab Rat
23 posts

it’s not worked!

i change my main to this

  1. #include "ekgsplash.h"
  2.  
  3. int main(int argc, char *argv[])
  4. {
  5.     QApplication Foad(argc, argv);
  6.  
  7.     QTranslator myappTranslator;
  8.     QString app_name = "foad_";
  9.     myappTranslator.load("foad_fa.qm");
  10.     Foad.installTranslator(&myappTranslator);
  11.  
  12.     QApplication::setLayoutDirection(Qt::RightToLeft);
  13.     Foad.setLayoutDirection(Qt::RightToLeft);
  14.     EKGsplash *splashScreen = new EKGsplash();
  15.     splashScreen->show();
  16.  
  17.     EKGWindow *ekgwindow = new EKGWindow();
  18.  
  19.     QObject::connect(splashScreen,SIGNAL(splashShowed()),ekgwindow,SLOT(show()));
  20.  
  21.     return Foad.exec();
  22. }

if it’s incorrect say

September 5, 2011

Pooyan Pooyan
Lab Rat
1 posts

Using QApplication::setLayoutDirection(Qt::RightToLeft) solves most of the problem. The only point remaining is that the title bar of the window will still be left to right. This can be solved using this in your window constructor:

  1. HWND hWnd = this->winId();
  2. long extendedStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
  3. SetWindowLong(hWnd, GWL_EXSTYLE, extendedStyle | WS_EX_RIGHT | WS_EX_NOINHERITLAYOUT);

September 6, 2011

soroush soroush
Lab Rat
818 posts

Not a real answer, but also notice to install Persian translator of Qt itself in order to have a completely translated UI :) This way you don’t need to set direction for all of your forms anymore. It will set it automatically when you load translation. And also will set direction to LTR when uninstalling translator, for example when you change language of app to English.

Cheers

September 6, 2011

bijanbina bijanbina
Lab Rat
23 posts

Pooyan wrote:
Using QApplication::setLayoutDirection(Qt::RightToLeft) solves most of the problem. The only point remaining is that the title bar of the window will still be left to right. This can be solved using this in your window constructor:

  1. HWND hWnd = this->winId();
  2. long extendedStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
  3. SetWindowLong(hWnd, GWL_EXSTYLE, extendedStyle | WS_EX_RIGHT | WS_EX_NOINHERITLAYOUT);

it’s not work for qaction in menu!!!!!

September 6, 2011

bijanbina bijanbina
Lab Rat
23 posts

soroush wrote:
Not a real answer, but also notice to install Persian translator of Qt itself in order to have a completely translated UI :) This way you don’t need to set direction for all of your forms anymore. It will set it automatically when you load translation. And also will set direction to LTR when uninstalling translator, for example when you change language of app to English.

Cheers

ok how can i install Persian translator of Qt!
also what do you mean are you mean use Qt linguist?
i use Qt4 linguist but it’s not solved my problem

September 6, 2011

soroush soroush
Lab Rat
818 posts

You can download new version of Qt. It should contain Persian translation. If you have a limited internet access, I can send you .qm file

September 6, 2011

soroush soroush
Lab Rat
818 posts

Reading this post might help you:
ترجمهٔ فارسی کیوت [developer.qt.nokia.com]

September 7, 2011

bijanbina bijanbina
Lab Rat
23 posts

could you please specify the package name and also version number explicitly

September 7, 2011

soroush soroush
Lab Rat
818 posts

Persian translation is added is added at July 19th, 2011. So it should be published with Qt 4.7.4 I think… Also if you have Qt source code from gitorious, you can easily merge the code to your repository with git.

 
  ‹‹ QEvent::Wheel working on a deactivated window.      Set QWidget to be "unmovable" ››

You must log in to post a reply. Not a member yet? Register here!