Reputation: 455
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
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