Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt 表视图中的组合框_Qt_Qml_Qtquick2 - Fatal编程技术网

Qt 表视图中的组合框

Qt 表视图中的组合框,qt,qml,qtquick2,Qt,Qml,Qtquick2,我正在QML表视图中组合一个组合框,如下所示: TableView { id: reviewTable frameVisible: false sortIndicatorVisible: true width: parent.width; height: parent.height anchors.centerIn: parent TableViewColumn { resizable: true role: "S

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

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
}
因此,拉伸组合框以填充所有空间:

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

这似乎比较好地解决了这个问题。但是,在设置行委托时出现了一个新问题。当我点击该行时,它消失了!好的,这就是默认颜色为白色的行代理。当然,如果您定义自己的行代理,您必须自己绘制。