SwipeDelegate QML Type
스와이프 가능한 아이템 델리게이트. 더 보기...
Import Statement: | import QtQuick.Controls |
Inherits: |
속성
- swipe
- swipe.behind : Component
- swipe.behindItem : Item
- swipe.complete : bool
- swipe.enabled : bool
- swipe.left : Component
- swipe.leftItem : Item
- swipe.position : real
- swipe.right : Component
- swipe.rightItem : Item
- swipe.transition : Transition
첨부 속성
- pressed : bool
(since QtQuick.Controls 2.1 (Qt 5.8))
신호
- void swipe.closed()
(since QtQuick.Controls 2.2 (Qt 5.9))
- void swipe.completed()
(since QtQuick.Controls 2.1 (Qt 5.8))
- void swipe.opened()
(since QtQuick.Controls 2.2 (Qt 5.9))
첨부된 신호
- clicked()
(since QtQuick.Controls 2.1 (Qt 5.8))
방법
- void swipe.close()
(since QtQuick.Controls 2.1 (Qt 5.8))
- void swipe.open(enumeration side)
(since QtQuick.Controls 2.2 (Qt 5.9))
자세한 설명
스와이프델리게이트는 왼쪽이나 오른쪽으로 스와이프하여 더 많은 옵션이나 정보를 표시할 수 있는 뷰 항목을 표시합니다. ListView 와 같은 뷰에서 델리게이트로 사용됩니다.
다음 예제에서는 ListView 에서 왼쪽으로 스와이프하여 항목을 제거할 수 있도록 SwipeDelegate를 사용합니다:
ListView { id: listView anchors.fill: parent model: ListModel { ListElement { sender: "Bob Bobbleton"; title: "How are you going?" } ListElement { sender: "Rug Emporium"; title: "SALE! All rugs MUST go!" } ListElement { sender: "Electric Co."; title: "Electricity bill 15/07/2016 overdue" } ListElement { sender: "Tips"; title: "Five ways this tip will save your life" } } delegate: SwipeDelegate { id: swipeDelegate text: sender + " - " + title width: listView.width required property string sender required property string title required property int index ListView.onRemove: SequentialAnimation { PropertyAction { target: swipeDelegate property: "ListView.delayRemove" value: true } NumberAnimation { target: swipeDelegate property: "height" to: 0 easing.type: Easing.InOutQuad } PropertyAction { target: swipeDelegate property: "ListView.delayRemove" value: false } } swipe.right: Label { id: deleteLabel text: qsTr("Delete") color: "white" verticalAlignment: Label.AlignVCenter padding: 12 height: parent.height anchors.right: parent.right SwipeDelegate.onClicked: listView.model.remove(index) background: Rectangle { color: deleteLabel.SwipeDelegate.pressed ? Qt.darker("tomato", 1.1) : "tomato" } } } }
SwipeDelegate는 ItemDelegate 에서 API를 상속받으며, 이는 AbstractButton 에서 상속받습니다. 예를 들어 text 을 설정하고 AbstractButton API를 사용하여 clicks 에 반응할 수 있습니다.
스와이프 진행 상황과 스와이프 시 표시되어야 하는 구성 요소에 관한 정보는 모두 swipe 그룹화된 속성 객체를 통해 사용할 수 있습니다. 예를 들어 swipe.position
은 -1.0
~ 1.0
범위 내에서 스와이프 위치를 유지합니다. swipe.left
속성은 컨트롤을 오른쪽으로 스와이프할 때 표시할 항목을 결정하며, swipe.right
은 그 반대의 경우도 마찬가지입니다. 이러한 구성 요소의 위치는 애플리케이션에서 결정할 수 있습니다. 예를 들어 swipe.left
또는 swipe.right
의 위치를 지정하지 않으면 다음과 같은 일이 발생합니다:
swipe.left
및 swipe.right
이 각각 background 항목의 왼쪽과 오른쪽에 고정되어 있으면 다음과 같이 동작합니다:
swipe.left
및 swipe.right
을 사용하는 경우 컨트롤을 왼쪽 및 오른쪽 가장자리를 지나서 스와이프할 수 없습니다. 이러한 유형의 "래핑" 동작을 구현하려면 swipe.behind
을 대신 설정하세요. 이렇게 하면 컨트롤을 스와이프하는 방향에 관계없이 동일한 항목이 표시됩니다. 예를 들어 아래 이미지에서는 swipe.behind
을 설정한 다음 컨트롤을 양방향으로 반복적으로 스와이프합니다:
스와이프 델리게이트 사용자 지정, 델리게이트 컨트롤 및 갤러리 예시도참조하세요 .
속성 문서
이름 | 설명 |
---|---|
위치 | 이 읽기 전용 프로퍼티는 컨트롤의 양쪽을 기준으로 스와이프의 위치를 유지합니다. 이 값이 -1.0 (왼쪽) 또는 1.0 (오른쪽)에 도달한 후 마우스 버튼을 놓으면 complete 은 true 이 됩니다. |
complete | 이 읽기 전용 속성은 왼쪽 또는 오른쪽으로 스와이프한 후 컨트롤이 완전히 노출되었는지 여부를 유지합니다. 완료가 |
enabled | 이 속성은 컨트롤을 스와이프할 수 있는지 여부를 결정합니다. 이 속성은 QtQuick.Controls 2.2에 추가되었습니다. |
left | 이 속성은 왼쪽 델리게이트를 보유합니다. 왼쪽 델리게이트는 contentItem 와 background 모두 뒤에 위치합니다. SwipeDelegate 을 오른쪽으로 스와이프하면 이 항목이 서서히 드러납니다. 여기에는 대화형 및 비대화형 항목을 모두 사용할 수 있습니다. 일반적인 이벤트 처리 규칙이 적용되며, Button 같은 대화형 컨트롤을 사용하는 경우 버튼을 클릭하면 clicked()와 같은 SwipeDelegate 의 상호작용 신호가 발생하지 않습니다. |
behind | 이 속성은 SwipeDelegate 을 왼쪽과 오른쪽으로 스와이프할 때 표시되는 델리게이트를 보유합니다.
여기에는 대화형 및 비대화형 항목을 모두 사용할 수 있습니다. 일반적인 이벤트 처리 규칙이 적용되며, Button 같은 대화형 컨트롤을 사용하는 경우 버튼을 클릭하면 clicked()와 같은 SwipeDelegate 의 상호작용 신호가 발생하지 않습니다. |
right | 이 속성은 오른쪽 델리게이트를 보유합니다. 오른쪽 델리게이트는 contentItem 와 background 모두 뒤에 위치합니다. SwipeDelegate 을 왼쪽으로 스와이프하면 이 항목이 서서히 드러납니다. 여기에는 대화형 및 비대화형 항목을 모두 사용할 수 있습니다. 일반적인 이벤트 처리 규칙이 적용되며, Button 같은 대화형 컨트롤을 사용하는 경우 버튼을 클릭하면 clicked()와 같은 SwipeDelegate 의 상호작용 신호가 발생하지 않습니다. |
leftItem | 이 읽기 전용 속성은 left 컴포넌트에서 인스턴스화된 항목을 보유합니다.
|
behindItem | 이 읽기 전용 속성은 behind 컴포넌트에서 인스턴스화된 항목을 보유합니다.
|
rightItem | 이 읽기 전용 속성은 right 컴포넌트에서 인스턴스화된 항목을 보유합니다.
|
transition | 이 속성은 스와이프가 해제되거나 swipe.open() 또는 swipe.close()가 호출될 때 적용되는 전환을 저장합니다.SwipeDelegate { swipe.transition: Transition { SmoothedAnimation { velocity: 3; easing.type: Easing.InOutCubic } } } 이 속성은 Qt Quick Controls 2.2에서 추가되었습니다. |
contentItem, background, swipe.open() 및 swipe.close()도 참조하세요 .
첨부된 속성 문서
SwipeDelegate.pressed : bool |
이 속성은 swipe.left
, swipe.right
, 또는 swipe.behind
에서 선언된 비대화형 항목에 첨부하여 눌렀는지 감지할 수 있습니다. 항목은 swipe.complete
이 true
일 때만 눌릴 수 있습니다.
예를 들어
swipe.right: Label { anchors.right: parent.right height: parent.height text: "Action" color: "white" padding: 12 background: Rectangle { color: SwipeDelegate.pressed ? Qt.darker("tomato", 1.1) : "tomato" } }
마우스 및 터치 이벤트를 개별적으로 수신하는 여러 항목을 가질 수 있습니다. 예를 들어 swipe.right
항목에 두 가지 동작을 포함하려면 다음 코드를 사용합니다:
swipe.right: Row { anchors.right: parent.right height: parent.height Label { id: moveLabel text: qsTr("Move") color: "white" verticalAlignment: Label.AlignVCenter padding: 12 height: parent.height SwipeDelegate.onClicked: console.log("Moving...") background: Rectangle { color: moveLabel.SwipeDelegate.pressed ? Qt.darker("#ffbf47", 1.1) : "#ffbf47" } } Label { id: deleteLabel text: qsTr("Delete") color: "white" verticalAlignment: Label.AlignVCenter padding: 12 height: parent.height SwipeDelegate.onClicked: console.log("Deleting...") background: Rectangle { color: deleteLabel.SwipeDelegate.pressed ? Qt.darker("tomato", 1.1) : "tomato" } } }
각 background 항목의 color
할당이 레이블의 id
으로 첨부된 속성을 어떻게 한정하는지 주목하세요. 항목에 첨부된 속성을 사용하면 해당 항목이 이벤트를 수락하게 되므로 이 점이 중요합니다. 이전 예제에서 id
을 생략했다고 가정해 보겠습니다:
color: SwipeDelegate.pressed ? Qt.darker("tomato", 1.1) : "tomato"
Rectangle 백그라운드 항목은 레이블의 하위 항목이므로 자연스럽게 그 이전의 이벤트를 수신합니다. 실제로는 배경 색이 변경되지만 레이블의 onClicked
핸들러는 호출되지 않습니다.
이러한 항목에서 선언된 대화형 컨트롤(예: Button)의 경우 해당 pressed
속성을 대신 사용하세요.
SwipeDelegate 자체에 있는 프레스의 경우 pressed 속성을 사용합니다.
이 프로퍼티는 QtQuick.Controls 2.1(Qt 5.8)에 도입되었습니다.
clicked()도 참조하십시오 .
신호 문서
|
이 신호는 델리게이트가 닫힘으로 스와이프되어 전환이 완료되었을 때 발생합니다.
스와이프 취소 시 어떤 작업을 수행할 때 유용합니다. 예를 들어, 목록에 있는 델리게이트의 제거를 취소하는 데 사용할 수 있습니다.
참고: 해당 핸들러는 swipe.onClosed
입니다.
이 신호는 QtQuick.Controls 2.2(Qt 5.9)에서 도입되었습니다.
swipe 및 swipe.opened()도 참조하십시오 .
|
이 신호는 swipe.complete
이 true
이 될 때 발생합니다.
스와이프가 완료된 후 어떤 작업을 수행할 때 유용합니다. 예를 들어 델리게이트가 있는 목록에서 해당 델리게이트를 제거하는 데 사용할 수 있습니다.
참고: 해당 핸들러는 swipe.onCompleted
입니다.
이 신호는 QtQuick.Controls 2.1(Qt 5.8)에 도입되었습니다.
swipe 를참조하십시오 .
|
이 신호는 델리게이트가 열리고 전환이 완료되었을 때 발생합니다.
스와이프가 완료된 후 어떤 작업을 수행할 때 유용합니다. 예를 들어 목록에 있는 델리게이트를 제거하는 데 사용할 수 있습니다.
참고: 해당 핸들러는 swipe.onOpened
입니다.
이 신호는 QtQuick.Controls 2.2(Qt 5.9)에서 도입되었습니다.
swipe 및 swipe.closed()도 참조하십시오 .
첨부된 신호 문서
|
이 신호는 swipe.left
, swipe.right
또는 swipe.behind
에 선언된 비대화형 항목에 첨부하여 클릭에 반응할 수 있습니다. swipe.complete
이 true
일 때만 항목을 클릭할 수 있습니다.
이러한 항목에 선언된 대화형 컨트롤(예: Button)의 경우 해당 clicked()
신호를 대신 사용하세요.
SwipeDelegate 자체에 대한 클릭에 반응하려면 clicked() 신호를 사용합니다.
참고: 이벤트 관련 속성을 올바르게 사용하는 방법에 대한 자세한 내용은 pressed 문서를 참조하세요.
참고: 해당 핸들러는 onClicked
입니다.
이 신호는 QtQuick.Controls 2.1(Qt 5.8)에서 도입되었습니다.
pressed도 참조하십시오 .
메서드 문서
|
이 방법은 스와이프의 position
를 0
로 설정합니다. contentItem 및 background 의 x 위치에 대해 정의된 모든 애니메이션이 트리거됩니다.
이 메서드는 QtQuick.Controls 2.1(Qt 5.8)에 도입되었습니다.
swipe 및 swipe.open()도 참조하십시오 .
|
이 메서드는 지정된 side 에서 열리도록 스와이프의 position
을 설정합니다.
사용 가능한 값은 다음과 같습니다:
Constant | 설명 |
---|---|
SwipeDelegate.Left | position 은 1 으로 설정되어 스와이프가 왼쪽에서 열립니다. swipe.left 또는 swipe.behind 중 하나를 지정해야 하며, 그렇지 않으면 호출이 무시됩니다. |
SwipeDelegate.Right | position 은 -1 으로 설정되어 스와이프가 오른쪽에서 열립니다. swipe.right 또는 swipe.behind 중 하나를 지정해야 하며, 그렇지 않으면 호출이 무시됩니다. |
contentItem 및 background 의 x 위치에 대해 정의된 모든 애니메이션이 트리거됩니다.
이 메서드는 QtQuick.Controls 2.2(Qt 5.9)에서 도입되었습니다.
swipe 및 swipe.close()도 참조하십시오 .
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.