TableModelColumn QML Type

모델의 열을 나타냅니다. 더 보기...

Import Statement: import Qt.labs.qmlmodels

상세 설명

TableModelColumn 클래스는 TableModel 에서 열을 나타냅니다. TableModel 은 각 행이 객체이고 키가 정렬되지 않은 단순한 키-값 쌍의 목록인 JavaScript/JSON 데이터를 지원합니다.

{
    // Each property is one cell/column.
    checked: false,
    amount: 1,
    fruitType: "Apple",
    fruitName: "Granny Smith",
    fruitPrice: 1.50
},
// ...

그러나 Qt의 모델은 행과 열 인덱스를 통해 조작됩니다. TableModelColumn으로 열을 지정하면 Qt의 내장 역할과 각 행 객체의 모든 프로퍼티를 매핑할 수 있습니다.

import QtQuick
import QtQuick.Window
import Qt.labs.qmlmodels

Window {
    width: 400
    height: 400
    visible: true

    TableView {
        anchors.fill: parent
        columnSpacing: 1
        rowSpacing: 1
        boundsBehavior: Flickable.StopAtBounds

        model: TableModel {
            TableModelColumn { display: "checked" }
            TableModelColumn { display: "amount" }
            TableModelColumn { display: "fruitType" }
            TableModelColumn { display: "fruitName" }
            TableModelColumn { display: "fruitPrice" }

            // Each row is one type of fruit that can be ordered
            rows: [
                {
                    // Each property is one cell/column.
                    checked: false,
                    amount: 1,
                    fruitType: "Apple",
                    fruitName: "Granny Smith",
                    fruitPrice: 1.50
                },
                {
                    checked: true,
                    amount: 4,
                    fruitType: "Orange",
                    fruitName: "Navel",
                    fruitPrice: 2.50
                },
                {
                    checked: false,
                    amount: 1,
                    fruitType: "Banana",
                    fruitName: "Cavendish",
                    fruitPrice: 3.50
                }
            ]
        }
        delegate:  TextInput {
            text: model.display
            padding: 12
            selectByMouse: true

            onAccepted: model.display = text

            Rectangle {
                anchors.fill: parent
                color: "#efefef"
                z: -1
            }
        }
    }
}

TableModelColumn은 복잡한 행에 대한 기본적인 읽기 전용 지원도 제공합니다. 자세한 내용은 Supported Row Data Structures 을 참조하십시오.

참고: 위의 개념 대부분은 TreeModel 에서 각 행이 트리의 노드를 나타내는 것을 제외하고는 TreeModel 에도 적용됩니다.

지원되는 역할

TableModelColumn은 Qt::InitialSortOrderRole 을 제외한 모든 Qt's roles 을 지원합니다. 역할은 다음과 같은 방법으로 액세스할 수 있습니다.

text: display

required property string display

TableModelTableView참조하세요 .

© 2025 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.