表格视图中的组合框

ComboBox in a Tableview

我正在 QML 表视图中组合一个 ComboBox,如下所示:

TableView {
    id: reviewTable
    frameVisible: false
    sortIndicatorVisible: true
    width: parent.width; height: parent.height
    anchors.centerIn: parent

    TableViewColumn {
        resizable: true
        role: "SeriesDescription"
        title: "Series Description"
        width: 350
    }

    TableViewColumn {
        resizable: false
        role: "TimePoints"
        title: "Time Points"
        width: 100
    }

    TableViewColumn {
        role: "ImageType"
        title: "Image Type"
        width: 100
        delegate: Rectangle {
            anchors.fill: parent
            //anchors.verticalCenter: parent.verticalCenter
            ComboBox {
                model: ListModel {
                    ListElement {  text: "Veggies" }
                    ListElement {  text: "Fruits" }
                    ListElement {  text: "Cars"  }
                }
            }
        }
    }
}

但是,这会以一种奇怪的方式呈现组合框,其中的边界看起来有点截断。请参阅随附的屏幕截图。有谁知道如何解决这个问题?

这不是完美的解决方案,但无论如何...您可以通过设置 rowDelegate 来更改行高,例如:

rowDelegate: Item {
            height: 30
}

等等拉伸组合框以填充所有 space:

TableViewColumn {
        role: "ImageType"
        ...
        delegate: Rectangle {
            ComboBox {
                anchors.fill: parent
                anchors.margins: 2
                model: ListModel {
                    ...
                }
            }
        }
    }