1

RTL および LTR 言語をサポートする必要がある qml アプリケーションを作成していますが、インターフェイスはある程度柔軟である必要があり、アンカーは適切な UI を生成しない可能性があります

だから私はqml Grid、Column、およびRowLayoutを使用することを計画しました。それらはうまく機能しますが、使用するとミラーリングされません

LayoutMirroring.enabled: true
LayoutMirroring.childrenInherit: true

LayoutMirroring.enabled: trueでこれらのレイアウト コンポーネントを使用する方法はあります か? そうでない場合は、qml ポジショナー (Row、Column、および Grid) の幅と高さを設定して、境界項目の幅と高さを埋める方法はありますか?

4

2 に答える 2

1

LayoutMirroring は、RowLayout、ColumnLayout、または GridLayout では使用できません。代わりに、Row[View]、Column[View]、または Grid[View] を使用できます。詳細については、http: //qt-project.org/doc/qt-5.1/qtquick/qml-qtquick2-layoutmirroring.htmlを参照してください。

以下は、qml ポジショナーの簡単な例です。

Rectangle {
    width: 640
    height: 480
    color: "#303030"

    Rectangle {
        width: parent.width / 1.1
        height: parent.height / 1.1
        anchors.centerIn: parent
        color: "white"

        Grid {
            id: grid
            anchors.fill: parent

            columns: 2

            spacing: 6
            columnSpacing: spacing
            rowSpacing: spacing


            property int rowCount: Math.ceil(visibleChildren.length / columns)
            property real cellWidth: (width - (columns - 1) * columnSpacing) / columns
            property real cellHeight: (height - (rowCount - 1) * rowSpacing) / rowCount

            Rectangle {
                color: "#aa6666"
                width: grid.cellWidth
                height: grid.cellHeight
            }
            Rectangle {
                color: "#aaaa66"
                width: grid.cellWidth
                height: grid.cellHeight
            }
            Rectangle {
                color: "#9999aa"
                width: grid.cellWidth
                height: grid.cellHeight
            }
            Rectangle {
                color: "#6666aa"
                width: grid.cellWidth
                height: grid.cellHeight
            }
        }
    }
}

列の数を変更し、いくつかの長方形を追加または削除して、機能することを確認します。

于 2013-09-24T16:00:20.373 に答える
1

Qt 5.2 では、RowLayout、ColumnLayout、および GridLayout には、RTL レイアウトをサポートするための layoutDirection プロパティがあります。

于 2014-11-04T13:39:02.980 に答える