Qt World Summit: Submit your Presentation

Combobox not closing when delegate of the listview goes out of scope

  • Hi all,

    I have made a delegate for listview that contains Combobox. If I opened the Combobox and scrolls the listview the Combobox popup is moving with the delegate position that's ok. But when the delegate goes out of the listview area Combobox popup continues to moves even out of the listview area.

    How to close the Combobox when the corresponding delegate goes out of the listview area.

    Thanks in advance...

    Out of scope view
    Screenshot from 2020-04-05 19-45-42.png


    Normal view
    Screenshot from 2020-04-05 19-45-28.png

  • Lifetime Qt Champion


    What version of Qt are you using.?
    On what OS ?
    Can you provide a minimal compilable example that shows that behaviour ?

  • @SGaist My environment details and I have added the code here

    OS - Ubuntu 18.04
    Qt version - 5.9.6

    import QtQuick 2.9
    import QtQuick.Window 2.2
    import QtQuick.Controls 2.2
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        Column {
            spacing: 0
            anchors.fill: parent
            Item {
                width: parent.width
                height: parent.height * 0.4
                Image {
                    anchors.fill: parent
                    anchors.margins: 10
                    source: "https://lh4.googleusercontent.com/proxy/cITVCAj9KJ5Hfwd5iuNDhzdB2pSrMQv2rzTl-vvg23he2qdCisZBG-MzV35y_r2zijC9X4QOpda9eHzr_hA"
            ListView {
                width: parent.width
                height: parent.height * 0.6
                model: 10
                spacing: 5
                clip: true
                highlightRangeMode: ListView.StrictlyEnforceRange
                delegate: Rectangle {
                    width: parent.width
                    height: 50
                    color: index % 2 == 0 ? "lightsteelblue" : "steelblue"
                    Row {
                        spacing: 25
                        anchors.centerIn: parent
                        Label {
                            text: qsTr("%1").arg(index)
                            anchors.verticalCenter: parent.verticalCenter
                        ComboBox {
                            anchors.verticalCenter: parent.verticalCenter
                            model: ["a", "b", "c"]

Log in to reply