このページでは

Qt Quick 例 - ポジショナー

こちらは、QMLのポジショナーに関するサンプル集です。

「Column」、「Row」、「Grid」、「Flow」の各ポジショナーレイアウトに配置された色付きの矩形

「ポジショナー」は、ポジショナーに関連する小規模なQMLサンプル集です。各サンプルは、特定のタイプや機能を強調した小さなQMLファイルです。詳細については、「Qt Quick における重要な概念 - 位置指定」をご覧ください。

例の動作確認

以下の手順でサンプルを実行できます:

トランジション

「Transitions」では、ポジショナー内のアイテムを表示または非表示にする際のアニメーション遷移が表示されます。このシーンには、Column 、Row 、Grid 、Flow といったさまざまなポジショナーに配置されたアイテムが含まれています。各ポジショナーには、「Transitions」として定義されたアニメーションが設定されています。

move: Transition {
    NumberAnimation {
        properties: "x,y"
        easing.type: Easing.OutBounce
    }
}

「移動トランジション」は、他のアイテムの出現や消失によって位置がずれた際、ポジショナー内のアイテムがどのようにアニメーションするかを指定します。

add: Transition {
    NumberAnimation {
        properties: "x,y"
        easing.type: Easing.OutBounce
    }
}

「add」トランジションは、アイテムがポジショナーに追加されたときにどのように表示されるかを指定します。

populate: Transition {
    NumberAnimation {
        properties: "x,y"
        from: 200
        duration: 100
        easing.type: Easing.OutBounce
    }
}

「populate」トランジションは、親ポジショナーが最初に作成されたときに、その中のアイテムがどのように表示されるかを指定します。

アタッチされたプロパティ

「アタッチされたプロパティ」では、Positioner のアタッチされたプロパティを使用して、ポジショナー内のアイテムの位置を特定する方法について説明しています。

Rectangle {
    id: green
    color: "#80c342"
    width: 100 * page.ratio
    height: 100 * page.ratio

    Text {
      anchors.left: parent.right
      anchors.leftMargin: 20
      anchors.verticalCenter: parent.verticalCenter
      text: qsTr("Index: %1%2%3").arg(parent.Positioner.index)
                .arg(parent.Positioner.isFirstItem ? qsTr(" (First)") : "")
                .arg(parent.Positioner.isLastItem ? qsTr(" (Last)") : "")
    }

    // When mouse is clicked, display the values of the positioner
    MouseArea {
        anchors.fill: parent
        onClicked: column.showInfo(green.Positioner)
    }
}

サンプルプロジェクト @ code.qt.io

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.