![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
#include <qquickselectionrectangle_p_p.h>
Definition at line 32 of file qquickselectionrectangle_p_p.h.
QT_BEGIN_NAMESPACE QQuickSelectionRectanglePrivate::QQuickSelectionRectanglePrivate | ( | ) |
Used to select table cells inside a TableView.
\qmltype SelectionRectangle \inherits Control
! \nativetype QQuickSelectionRectangle \inqmlmodule QtQuick.Controls
SelectionRectangle is used for selecting table cells in a TableView. It lets the user start a selection by doing a pointer drag inside the viewport, or by doing a long press on top of a cell.
For a SelectionRectangle to be able to select cells, TableView must have an ItemSelectionModel assigned. The ItemSelectionModel will store any selections done on the model, and can be used for querying which cells that the user has selected.
The following example shows how you can make a SelectionRectangle target a TableView:
\qmlproperty Item QtQuick.Controls::SelectionRectangle::target
This property holds the TableView on which the SelectionRectangle should act.
\qmlproperty bool QtQuick.Controls::SelectionRectangle::active \readonly
This property is true
while the user is performing a selection. The selection will be active from the time the the user starts to select, and until the selection is removed again, for example from tapping inside the viewport.
\qmlproperty bool QtQuick.Controls::SelectionRectangle::dragging \readonly
This property is true
whenever the user is doing a pointer drag or a handle drag to adjust the selection rectangle.
\qmlproperty Component QtQuick.Controls::SelectionRectangle::topLeftHandle
This property holds the delegate that will be shown on the center of the top-left corner of the selection rectangle. When a handle is provided, the user can drag it to adjust the selection.
The handle is not hidden by default when a selection is removed. Instead, this is the responsibility of the delegate, to open up for custom fade-out animations. The easiest way to ensure that the handle ends up hidden, is to simply bind \l {Item::}{visible} to the \l active state of the SelectionRectangle:
\qml SelectionRectangle { topLeftHandle: Rectangle { width: 20 height: 20 visible: SelectionRectangle.control.active } } \endqml
Set this property to null
if you don't want a selection handle on the top-left.
\qmlproperty Component QtQuick.Controls::SelectionRectangle::bottomRightHandle
This property holds the delegate that will be shown on the center of the top-left corner of the selection rectangle. When a handle is provided, the user can drag it to adjust the selection.
The handle is not hidden by default when a selection is removed. Instead, this is the responsibility of the delegate, to open up for custom fade-out animations. The easiest way to ensure that the handle ends up hidden, is to simply bind \l {Item::}{visible} to the \l active state of the SelectionRectangle:
\qml SelectionRectangle { bottomRightHandle: Rectangle { width: 20 height: 20 visible: SelectionRectangle.control.active } } \endqml
Set this property to null
if you don't want a selection handle on the bottom-right.
\qmlproperty enumeration QtQuick.Controls::SelectionRectangle::selectionMode
This property holds when a selection should start.
\value SelectionRectangle.Drag A selection will start by doing a pointer drag inside the viewport \value SelectionRectangle.PressAndHold A selection will start by doing a press and hold on top of a cell \value SelectionRectangle.Auto SelectionRectangle will choose which mode to use based on the \l target and the input device in use. This normally means Drag
when using a mouse, and PressAndHold
on a touchscreen. However, Drag
will only be used if it doesn't conflict with flicking. One way to avoid conflict is to disable mouse-drag flicking by setting \l {Flickable::}{acceptedButtons} to Qt.NoButton
. In that case, the mouse wheel or touchpad scrolling gesture continues to work, touchscreen flicking continues to work, and touchscreen selection can be started by press-and-hold. Another way is to set \l {Flickable::}{interactive} to false
, which disables flicking and scrolling altogether (perhaps this should be done only temporarily, in some mode in your UI). Yet another way is to place the TableView inside a ScrollView (where flicking, by default, is off for mouse events).
The default value is Auto
.
\qmlattachedproperty SelectionRectangle QtQuick.Controls::SelectionRectangle::control
This attached property holds the SelectionRectangle that manages the delegate instance. It is attached to each handle instance.
\qmlattachedproperty bool QtQuick.Controls::SelectionRectangle::dragging
This attached property will be true
if the user is dragging on the handle. It is attached to each handle instance.
Definition at line 170 of file qquickselectionrectangle.cpp.
void QQuickSelectionRectanglePrivate::connectToTarget | ( | ) |
Definition at line 511 of file qquickselectionrectangle.cpp.
References m_selectable, updateActiveState(), and updateHandles().
QQuickItem * QQuickSelectionRectanglePrivate::createHandle | ( | QQmlComponent * | delegate, |
Qt::Corner | corner ) |
Definition at line 409 of file qquickselectionrectangle.cpp.
References m_selectable.
QQuickSelectionRectangleAttached * QQuickSelectionRectanglePrivate::getAttachedObject | ( | const QObject * | object | ) | const |
Definition at line 583 of file qquickselectionrectangle.cpp.
QQuickItem * QQuickSelectionRectanglePrivate::handleUnderPos | ( | const QPointF & | pos | ) |
Definition at line 361 of file qquickselectionrectangle.cpp.
References m_selectable.
Definition at line 350 of file qquickselectionrectangle.cpp.
void QQuickSelectionRectanglePrivate::updateActiveState | ( | bool | isActive | ) |
Definition at line 390 of file qquickselectionrectangle.cpp.
References m_active.
Referenced by connectToTarget().
void QQuickSelectionRectanglePrivate::updateDraggingState | ( | bool | isDragging | ) |
Definition at line 379 of file qquickselectionrectangle.cpp.
References m_dragging.
void QQuickSelectionRectanglePrivate::updateHandles | ( | ) |
Definition at line 490 of file qquickselectionrectangle.cpp.
References m_selectable.
Referenced by connectToTarget().
void QQuickSelectionRectanglePrivate::updateSelectionMode | ( | ) |
Definition at line 539 of file qquickselectionrectangle.cpp.
bool QQuickSelectionRectanglePrivate::m_active = false |
Definition at line 73 of file qquickselectionrectangle_p_p.h.
Referenced by updateActiveState().
QScopedPointer<QQuickItem> QQuickSelectionRectanglePrivate::m_bottomRightHandle |
Definition at line 57 of file qquickselectionrectangle_p_p.h.
QQmlComponent* QQuickSelectionRectanglePrivate::m_bottomRightHandleDelegate = nullptr |
Definition at line 55 of file qquickselectionrectangle_p_p.h.
QPointer<QQuickItem> QQuickSelectionRectanglePrivate::m_draggedHandle |
Definition at line 58 of file qquickselectionrectangle_p_p.h.
bool QQuickSelectionRectanglePrivate::m_dragging = false |
Definition at line 74 of file qquickselectionrectangle_p_p.h.
Referenced by updateDraggingState().
QQuickDragHandler* QQuickSelectionRectanglePrivate::m_dragHandler = nullptr |
Definition at line 63 of file qquickselectionrectangle_p_p.h.
QQuickSelectionRectangle::SelectionMode QQuickSelectionRectanglePrivate::m_effectiveSelectionMode = QQuickSelectionRectangle::Drag |
Definition at line 70 of file qquickselectionrectangle_p_p.h.
bool QQuickSelectionRectanglePrivate::m_enabled = true |
Definition at line 72 of file qquickselectionrectangle_p_p.h.
Definition at line 67 of file qquickselectionrectangle_p_p.h.
QTimer QQuickSelectionRectanglePrivate::m_scrollTimer |
Definition at line 65 of file qquickselectionrectangle_p_p.h.
QPointF QQuickSelectionRectanglePrivate::m_scrollToPoint |
Definition at line 66 of file qquickselectionrectangle_p_p.h.
QQuickSelectable* QQuickSelectionRectanglePrivate::m_selectable = nullptr |
Definition at line 60 of file qquickselectionrectangle_p_p.h.
Referenced by connectToTarget(), createHandle(), handleUnderPos(), and updateHandles().
QQuickSelectionRectangle::SelectionMode QQuickSelectionRectanglePrivate::m_selectionMode = QQuickSelectionRectangle::Auto |
Definition at line 69 of file qquickselectionrectangle_p_p.h.
QQuickTapHandler* QQuickSelectionRectanglePrivate::m_tapHandler = nullptr |
Definition at line 62 of file qquickselectionrectangle_p_p.h.
QPointer<QQuickItem> QQuickSelectionRectanglePrivate::m_target |
Definition at line 52 of file qquickselectionrectangle_p_p.h.
QScopedPointer<QQuickItem> QQuickSelectionRectanglePrivate::m_topLeftHandle |
Definition at line 56 of file qquickselectionrectangle_p_p.h.
QQmlComponent* QQuickSelectionRectanglePrivate::m_topLeftHandleDelegate = nullptr |
Definition at line 54 of file qquickselectionrectangle_p_p.h.