首页 > 解决方案 > Qml TreeView 只选择单元格而不是行

问题描述

我有一个 Treeview,我希望能够连续选择单元格并能够使用 Ctrl+C 复制它,但现在我只能选择行。我错过了 QML 代码中的某些内容还是取决于模型?

我的桌子

TreeView {
    anchors.bottom: parent.bottom
    anchors.top: rect.bottom
    anchors.left: parent.left
    anchors.right: parent.right
    anchors.margins: 10

    model: modelka

    itemDelegate: Item {
        Text {
            anchors.verticalCenter: parent.verticalCenter
            color: "#000000"
            elide: Text.ElideRight
            text: styleData.value
            width: parent.width
            font.italic: modelka.data(styleData.index, 260)
        }
    }

    TableViewColumn {
        id: nameCol
        title: "Наименование"
        role: "name"
        width: 220
    }
    TableViewColumn {
        title: "Значение"
        role: "value"
        width: 240
    }
    TableViewColumn {
        id: unitCol
        title: "Ед.Изм."
        role: "unit"
        width: 80
    }

    rowDelegate: Rectangle {
        color: getColor(styleData.selected, styleData.row)
    }
}

标签: qtqml

解决方案


推荐阅读