Important: Please read the Qt Code of Conduct -

Probelem with MouseArea and comboBox drop down footer

  • Hello,
    I have a ComboBox with a list view as a popup. This list view has a footer which needs to change color depending if the mouse is hovering above it or not....
    What I observe is that when I click onthe comboBox and the popUp opens, the mouse area associated with the footer received an onEntered message (which is incorrect as there if 4 or 5 objects in my list view model). This triggers me to set the footer to the hovered color...
    Then, as soon as I move the mouse, even by 1 pixel, the mouse area receives an on exit message, at which point I correctly notice that the mouse is NOT in the footer and change the color...
    It looks as if the system first puts the footer in the control, triggers the mouse area, then adds the rest of the model, but that the mouse are does not get told of the change... But I have not looked in the QT code in details to check...
    Is this a QT bug, or am I missing something?

            contentItem: ListView {
                clip: true
                implicitHeight: contentHeight
                model: control.delegateModel
                footer: Item {
                    width: parent.width
                    height: control.implicitHeight
                    Rectangle {
                        id: footerTopRect
                        // There seems to be a problem in QT here...
                        // When the list popsup, it only has one item, the footer and as a result
                        // the mouse is seen as being in the footer, thus the mouseArea "enters"
                        // and onMore gets set to true...
                        // then the system noticed that there is such thing as a model and "add them"...
                        // this moves the position of the footer, BUT the mouse area onExit is NOT triggered
                        // and onMore stays true, this resulting in the wrong color there...
                        // Unfortunately, this happends AFTER the onOpened signal, so setting onMore to false there does not help...
                        color: comboPopup.onMore ? AppTheme.primaryHover : AppTheme.primaryBlue
                        height: backRect.radius
                        anchors.left: footerRoundRect.left
                        anchors.right: footerRoundRect.right
                    MyLabel {
                        anchors.fill: parent
                        leftPadding: 10
                        font.weight: Font.Light
                        text: qsTrId("More")
                    MouseArea {
                        anchors.fill: parent
                        hoverEnabled: true
                        onEntered: comboPopup.onMore = true
                        onExited: comboPopup.onMore = false

Log in to reply