Hi,

I tried to use a QML ListView and wondered why it does not react to mouse 
clicks. After looking into the examples I found out that you need to add a 
MouseArea in the delegate. Without this code the ListView is unusable because 
the user can not select anything using the mouse.

Shouldn't the MouseArea be the default behaviour without writing this code 
every time? Only if the user wants to do custom things he should need to 
override this.

The documentation seems to contain no statements about the MouseArea needed. 
This is essential for the usability and it should be mentioned in ListView the 
documentation at least.

Best regards,

Rainer
import QtQuick 2.0

Rectangle {
    width: 150
    height: 150

    ListModel {
        id: datamodel
        ListElement { str: "Foo" }
        ListElement { str: "Bar" }
        ListElement { str: "Tmp" }
    }

    ListView {
        anchors.fill: parent
        model: datamodel
        highlight: Rectangle { color: "lightsteelblue"; radius: 5 }

        delegate: Text {
                text: str
                font.pointSize: 20
                MouseArea {
                    anchors.fill: parent
                    onClicked: { parent.ListView.view.currentIndex = index }
                }
        }
    }
}
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to