morteza ali ahmadi
morteza ali ahmadi

Reputation: 455

Qt Qmenu set layout direction to right does not work

In Qt I use a QMenuBar and add some menus to it. My program is multi language and when I use a left to right language like English, every thing is OK, and when I choose a language which has right to left direction, I have to add this line to my main.cpp:

MainWindow w;
w.setLayoutDirection(Qt::RightToLeft);

So every widgets move to right except QMenubar.

I also add this line to my QMenuBar:

ui->menubar->setLayoutDirection(Qt::RightToLeft);

and

QApplication::setLayoutDirection(Qt::RightToLeft);

But nothing happens.

Should I set/change another option?

Upvotes: 0

Views: 783

Answers (1)

Suvorov Ivan
Suvorov Ivan

Reputation: 69

It helped me to override QMenu::item and QMenu::item:selected styles, for example

settingsList->setStyleSheet("QMenu::item { background-color: white; } QMenu::item:selected { background-color: blue; }");
settingsList->setLayoutDirection(Qt::RightToLeft);

Upvotes: 0

Related Questions