QQuickTreeViewDelegate: add some docs about pointer handlers
Change-Id: I7590d07359a09408274bc7e355aad3f754c80b34 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
parent
301c2c9341
commit
94b3bedbf0
|
@ -99,6 +99,39 @@ QT_BEGIN_NAMESPACE
|
||||||
is controlled with \l [QML]{Control::}{spacing}. And the space to the right of the
|
is controlled with \l [QML]{Control::}{spacing}. And the space to the right of the
|
||||||
contentItem is controlled with \l rightMargin.
|
contentItem is controlled with \l rightMargin.
|
||||||
|
|
||||||
|
\section2 Interacting with pointers
|
||||||
|
TreeViewDelegate inherits \l AbstractButton. This means that it will emit signals
|
||||||
|
such as \l {AbstractButton::clicked()}{clicked} when the user clicks on the delegate.
|
||||||
|
If needed, you could connect to that signal to implement application specific
|
||||||
|
functionality, in addition to the default expand/collapse behavior (and even set \l
|
||||||
|
{QQuickTableView::pointerNavigationEnabled}{pointerNavigationEnabled} to \c false, to
|
||||||
|
disable the default behavior as well).
|
||||||
|
|
||||||
|
But the AbstractButton API does not give you information about the position of the
|
||||||
|
click, or which modifiers are being held. If this is needed, a better approach would
|
||||||
|
be to use pointer handlers. To ensure that they don't interfere with the
|
||||||
|
existing logic in TreeViewDelegate, install them on a child item, e.g:
|
||||||
|
|
||||||
|
\code
|
||||||
|
TreeView {
|
||||||
|
id: treeView
|
||||||
|
delegate: TreeViewDelegate {
|
||||||
|
Item {
|
||||||
|
anchors.fill: parent
|
||||||
|
TapHandler {
|
||||||
|
acceptedModifiers: Qt.ControlModifier
|
||||||
|
onTapped: {
|
||||||
|
if (treeView.isExpanded(row))
|
||||||
|
treeView.collapseRecursively(row)
|
||||||
|
else
|
||||||
|
treeView.expandRecursively(row)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
\endcode
|
||||||
|
|
||||||
\sa TreeView
|
\sa TreeView
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue