diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-11-17 09:14:08 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-11-17 10:24:27 +0000 |
commit | fe34af03e3e673419513ef139b67321b0ad17e7e (patch) | |
tree | 15edd232a8964297ced4b4d0e2a1e755c82d9a52 | |
parent | 6a86efd93906c688b22b8a847e9c7d380d951dab (diff) |
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 <mitch.curtis@qt.io>
-rw-r--r-- | examples/quickcontrols2/contactlist/ContactDelegate.ui.qml | 24 |
1 files changed, 5 insertions, 19 deletions
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 |