From fe34af03e3e673419513ef139b67321b0ad17e7e Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 17 Nov 2016 09:14:08 +0100 Subject: Contact List example: make ContactDelegate.ui.qml designable Replace the MouseArea and its onClicked signal handler with a checkable AbstractButton to achieve declarative bindings and that way make it possible to open ContactDelegate.ui.qml in Qt Quick Designer. Change-Id: I764e0adc23d4a0d44dd6660ed14e224a4e0e30c7 Reviewed-by: Mitch Curtis --- .../contactlist/ContactDelegate.ui.qml | 24 +++++----------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'examples/quickcontrols2/contactlist') diff --git a/examples/quickcontrols2/contactlist/ContactDelegate.ui.qml b/examples/quickcontrols2/contactlist/ContactDelegate.ui.qml index 0ca9cedc..fb3d88eb 100644 --- a/examples/quickcontrols2/contactlist/ContactDelegate.ui.qml +++ b/examples/quickcontrols2/contactlist/ContactDelegate.ui.qml @@ -51,8 +51,10 @@ import QtQuick 2.7 import QtQuick.Controls 2.1 -Item { +AbstractButton { clip: true + checkable: true + autoExclusive: true id: delegate @@ -61,22 +63,6 @@ Item { property alias edit: edit width: 300 - MouseArea { - id: mouseArea - anchors.fill: parent - } - - Connections { - target: mouseArea - - onClicked: { - if (delegate.ListView.view.currentIndex === index) - delegate.ListView.view.currentIndex = -1 - else - delegate.ListView.view.currentIndex = index - } - } - Column { id: column1 height: 400 @@ -174,11 +160,11 @@ Item { states: [ State { name: "collapsed" - when: !delegate.ListView.isCurrentItem + when: !delegate.checked }, State { name: "expanded" - when: delegate.ListView.isCurrentItem + when: delegate.checked PropertyChanges { target: delegate -- cgit v1.2.3