QML: Button in footer unresponsive when using ListView.OverlayFooter

Viewed 591

EDIT : The issue seems to be related with Qt 5.15 and does not show up with Qt 5.14 !

I'm learning QML and made an app composed of a Window containing a ListView.

I'm trying to add a Button, which should be at a fixed position at the bottom of the window (it shouldn't move when I scroll). Thus, I decided to add this Button to the footer attribute of the ListView, and set footerPositioning: ListView.OverlayFooter

However, doing so makes the button totally unresponsive. If I comment out the footerPositioning line, the button works as expected, but is wrongly placed.

The documentation states that "If footerPositioning is not set to ListView.InlineFooter, the user cannot press and flick the list from the footer. In any case, the footer item may contain items or event handlers that provide custom handling of mouse or touch input" ; which to me doesn't say that the item (here a button) event handling shoudn't work.

Here is an exemple of code that shows the unresponsive button behaviour :

Debug.qml

import QtQuick 2.9
import QtQuick.Window 2.9
import QtQuick.Layouts 1.9
import QtQuick.Controls 2.9

Window {

    visible: true
    width: 260
    height: 520

    ListView {
        anchors.fill: parent
        clip: true
        spacing: 6
        model: 4

        delegate: RowLayout {
            width: parent.width
            Rectangle {
                Layout.fillWidth: true
                height: 60
                color: "#ff0000"
            }
        }

        footerPositioning: ListView.OverlayFooter // comment out this line to make the button responsive
        footer: Button {
            height: 180
            width: 90
            background: Rectangle {
                id: backbtn
                color: "gray"
            }

            onClicked: {
                backbtn.color = "#00ff00"
            }
        }
    }
}

main.cpp

#include <QGuiApplication>
#include <QQmlApplicationEngine>

int main(int argc, char *argv[])
{
#if defined(Q_OS_WIN)
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif

    QGuiApplication app(argc, argv);
    QQmlApplicationEngine engine;

    engine.load(QUrl(QStringLiteral("qrc:/Debug.qml")));

    if (engine.rootObjects().isEmpty()) {
        return -1;
    }

    return app.exec();
}

How can I make the button responsive while keeping ListView.OverlayFooter ?

2 Answers

This issue is bug-related, as identified by Thomenson. In Qt 5.15, using a ListView with clip enabled and ListView.OverlayFooter seems to disable mouse event handling in the footer.

Switching from Qt 5.15 to Qt 5.14 fixes the problem.

The bugtracker to the related issue can be found here : bugreports.qt.io/browse/QTBUG-85302

We can't downgrade so until QTBUG-85302 is fixed workaround is to set clip: false for the ListView and clip: true for the parent container item: Rectangle or Item, which has same size.

Related