我的默认QT程序语言是english
,因为english
是left to right
我左边有一个菜单和一些按钮,但是当我将程序的语言更改为有right to left
方向,放置菜单和左边的按钮是没有意义的。
所以我想知道是否可以选择将所有小部件撤销到正确的位置?
答案 0 :(得分:6)
使用QML,已经有大量关于如何操作的文档,最明显的是layoutDirection: Qt.RightToLeft
属性,它将所有小部件的子节点与标准顺序相反的顺序放置
http://doc.qt.io/qt-5/qtquick-positioning-righttoleft.html
您还可以选择使用main.cpp开头的qApp->setLayoutDirection (Qt::RightToLeft);
代码行进行全局设置
https://witekio.com/blog/qt-internationalization-arabic-chinese-right-left/
链接页面的示例:
Page {
LayoutMirroring.enabled: (Qt.application.layoutDirection === Qt.RightToLeft)
LayoutMirroring.childrenInherit: true
Row {
// Row will use right-to-left order when LayoutMirror.enabled = true
Text {
id: songNumber
text: "1."
horizontalAlignment: Text.AlignLeft // Alignment will adjust too. But don't fail to mention it
// or the text won't change its alignment
Text {
id: artistItem
text: "Some Artist"
horizontalAlignment: Text.AlignLeft
// Manually change elide side
elide: (Qt.application.layoutDirection === Qt.LeftToRight) ?
Text.ElideRight : Text.ElideLeft
}
}
}