如何在列表视图qml中突出显示当前项

时间:2018-08-12 14:33:56

标签: qt listview qml highlight

我想使用高光对显示的图像进行打勾。我使用了highlightFollowsCurrentItem: true ,但是没有用。我需要帮助

Component {
    id: highlight
    Rectangle {
        id: rot
        width: 162; height: 92
        color: "lightgray"
        x: listview.currentItem.x
        z:3
        opacity: 0.4
        Behavior on x {
            SpringAnimation {
                spring: 4
                damping: 0.8
            }
        }
    }
}

ListView {
    id: listview
    height: 100
    spacing: 14.55
    model: images
    visible: true
    anchors{
        left: parent.left
        right: parent.right
        bottom: parent.bottom
    }
    orientation: Qt.Horizontal
    delegate:
        Image {
        width: 160
        height: 90
        source: modelData
        MouseArea{
            anchors.fill: parent
            onClicked: {
                listview.currentIndex = index
                show.source = fileDialog.fileUrls[index]
                i = index
                console.log("xxxx" + index)

            }
        }
    }

    highlight: highlight
    highlightFollowsCurrentItem: true
    focus: true

}

0 个答案:

没有答案