Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. ComboBox Popup.Window does not receive mouse clicks

ComboBox Popup.Window does not receive mouse clicks

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 101 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    euing
    wrote on last edited by euing
    #1

    Hi,

    I’m using a ComboBox in QML, and I set its popup to Popup.Window so that the popup appears in a separate window.
    The ComboBox implementation itself is directly based on the Qt documentation example (CustomComboBox.qml is basically unchanged from the official example).

    Here’s my setup:

    Main.qml

    Window {
        id: window
    
        width: 640
        height: 480
        visible: true
    
        flags: Qt.Window | Qt.FramelessWindowHint
        color: "white"
    
        CustomComboBox {
            id: comboBox
            width: 300
            height: 200
            popup.popupType: Popup.Window
    
            model: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"]
        }
    
        MouseArea {
            anchors.top: comboBox.bottom
            width: 300
            height: 100
    
            onClicked: {
                console.log("clicked!")
            }
        }
    }
    

    CustomComboBox.qml

    ComboBox {
        id: control
    
        delegate: ItemDelegate {
            id: delegate
    
            required property var model
            required property int index
    
            width: control.width
            contentItem: Text {
                text: delegate.model[control.textRole]
                color: "#21be2b"
                font: control.font
                elide: Text.ElideRight
                verticalAlignment: Text.AlignVCenter
            }
            highlighted: control.highlightedIndex === index
        }
    
        indicator: Canvas {
            id: canvas
            x: control.width - width - control.rightPadding
            y: control.topPadding + (control.availableHeight - height) / 2
            width: 12
            height: 8
            contextType: "2d"
    
            Connections {
                target: control
                function onPressedChanged() { canvas.requestPaint(); }
            }
    
            onPaint: {
                context.reset();
                context.moveTo(0, 0);
                context.lineTo(width, 0);
                context.lineTo(width / 2, height);
                context.closePath();
                context.fillStyle = control.pressed ? "#17a81a" : "#21be2b";
                context.fill();
            }
        }
    
        contentItem: Text {
            leftPadding: 0
            rightPadding: control.indicator.width + control.spacing
    
            text: control.displayText
            font: control.font
            color: control.pressed ? "#17a81a" : "#21be2b"
            verticalAlignment: Text.AlignVCenter
            elide: Text.ElideRight
        }
    
        background: Rectangle {
            implicitWidth: 120
            implicitHeight: 40
            border.color: control.pressed ? "#17a81a" : "#21be2b"
            border.width: control.visualFocus ? 2 : 1
            radius: 2
        }
    
        popup: Popup {
            y: control.height - 1
            width: control.width
            height: Math.min(contentItem.implicitHeight, control.Window.height - topMargin - bottomMargin)
            padding: 1
    
            contentItem: ListView {
                clip: true
                implicitHeight: contentHeight
                model: control.popup.visible ? control.delegateModel : null
                currentIndex: control.highlightedIndex
    
                ScrollIndicator.vertical: ScrollIndicator { }
            }
    
            background: Rectangle {
                border.color: "#21be2b"
                radius: 2
            }
        }
    }
    

    Observed behavior:
    The popup itself does not receive mouse clicks in areas that overlap a MouseArea underneath.
    Mouse clicks on regions not overlapping any MouseArea are received normally by the popup.

    Has anyone experienced this issue or knows why the popup window cannot receive mouse clicks?

    Environment:
    Qt 6.9.1 on Windows 11

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved