PDA

View Full Version : Highlight problem for ListView entry when button pressed



zibo
26th October 2011, 13:44
Hello.
I'm new in QLM and I have a problem with some task related to QML ListView. I need to make entries highlighted when pointed by mouse and selected when clicked. Everything works ok untill I press a button on some entry an than move to another - hover doesn't work for other entries. It looks that pressed button blocks other elements (no onEntered, onExited and other signals of those elements). Here is a similar, simplified code (and without selection action for now):

ListDelegate.qml


import QtQuick 1.0

Rectangle {
id: delegate
width: ListView.view.width
height: 40

Rectangle {
id: background
anchors.fill: parent
color: mArea.containsMouse ? "thistle" : "lightsteelblue"
}
Text {
id: label
anchors.top: parent.top
anchors.topMargin: 2
anchors.left: parent.left
anchors.leftMargin: 2
font.family: "Helvetica";
font.pixelSize: 13;
font.bold: true
color: mArea.containsMouse ? "blue" : "red"
text: name + ":\n\t" + number + "\n"
}
MouseArea {
id: mArea
anchors.fill: parent
hoverEnabled: true
}
}


ContactModel.qml


import QtQuick 1.0

ListModel {
ListElement {
name: "Bill Smith"
number: "555 3264"
}
ListElement {
name: "John Brown"
number: "555 8426"
}
ListElement {
name: "Sam Wise"
number: "555 0473"
}
}


main.qml


import QtQuick 1.0

Rectangle {
width: 180; height: 200

ListView {
id: list
width: 180; height: 200
clip: true
interactive: false
model: ContactModel {}
delegate: ListDelegate {}
focus: true
}
}


Is there any solution?