Tumbler QML Type

선택할 수 있는 항목의 회전 가능한 휠입니다. 더 보기...

Import Statement: import QtQuick.Controls
Inherits:

Control

속성

첨부 속성

방법

  • void positionViewAtIndex(int index, PositionMode mode) (since QtQuick.Controls 2.5 (Qt 5.12))

상세 설명

Tumbler {
    model: 5
    // ...
}

텀블러는 사용자가 회전 가능한 '휠' 항목에서 옵션을 선택할 수 있도록 합니다. 예를 들어 RadioButton 과 같이 사용할 옵션이 너무 많거나 편집 가능한 SpinBox 을 사용해야 할 옵션이 너무 적을 때 유용합니다. 키보드를 사용할 필요가 없고 항목 수가 많을 때 양쪽 끝을 감싸기 때문에 편리합니다.

API는 ListViewPathView 과 같은 뷰와 유사하며 modeldelegate 을 설정할 수 있고 countcurrentItem 속성은 뷰에 대한 정보에 대한 읽기 전용 액세스를 제공합니다. 특정 인덱스에 뷰를 배치하려면 positionViewAtIndex()를 사용합니다.

그러나 PathViewListView 과 같은 뷰와 달리 항상 현재 항목이 있습니다(모델이 비어 있지 않은 경우). 즉, count0 과 같을 때 currentIndex-1 이 됩니다. 다른 모든 경우에는 0 보다 크거나 같을 것입니다.

기본적으로 텀블러는 모델에 보이는 항목 수보다 더 많은 항목이 있는 경우, 즉 countvisibleItemCount 보다 큰 경우 위쪽과 아래쪽에 도달하면 wraps 입니다:

import QtQuick
import QtQuick.Window
import QtQuick.Controls

Rectangle {
    width: frame.implicitWidth + 10
    height: frame.implicitHeight + 10

    function formatText(count, modelData) {
        var data = count === 12 ? modelData + 1 : modelData;
        return data.toString().length < 2 ? "0" + data : data;
    }

    FontMetrics {
        id: fontMetrics
    }

    Component {
        id: delegateComponent

        Label {
            text: formatText(Tumbler.tumbler.count, modelData)
            opacity: 1.0 - Math.abs(Tumbler.displacement) / (Tumbler.tumbler.visibleItemCount / 2)
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            font.pixelSize: fontMetrics.font.pixelSize * 1.25
        }
    }

    Frame {
        id: frame
        padding: 0
        anchors.centerIn: parent

        Row {
            id: row

            Tumbler {
                id: hoursTumbler
                model: 12
                delegate: delegateComponent
            }

            Tumbler {
                id: minutesTumbler
                model: 60
                delegate: delegateComponent
            }

            Tumbler {
                id: amPmTumbler
                model: ["AM", "PM"]
                delegate: delegateComponent
            }
        }
    }
}

텀블러입력 컨트롤사용자 지정하기를참조하세요 .

속성 문서

count : int [read-only]

이 속성은 모델에 있는 항목 수를 보유합니다.


currentIndex : int

이 속성은 현재 항목의 인덱스를 보유합니다.

count0 일 때 이 속성의 값은 -1 입니다. 다른 모든 경우에는 0 보다 크거나 같을 것입니다.

currentItempositionViewAtIndex()도 참조하세요 .


currentItem : Item [read-only]

이 속성은 현재 인덱스에 항목을 보유합니다.

currentIndexpositionViewAtIndex()도 참조하세요 .


delegate : Component

이 속성은 각 항목을 표시하는 데 사용되는 델리게이트를 보유합니다.


model : variant

이 속성은 이 텀블러에 대한 데이터를 제공하는 모델을 보유합니다.


moving : bool [since QtQuick.Controls 2.2 (Qt 5.9)]

이 속성은 사용자가 텀블러를 드래그하거나 플릭하여 텀블러가 현재 움직이고 있는지 여부를 설명합니다.

이 프로퍼티는 QtQuick.Controls 2.2(Qt 5.9)에 도입되었습니다.


visibleItemCount : int

이 프로퍼티는 텀블러에 표시되는 항목의 수를 보유합니다. 현재 항목은 항상 세로로 중앙에 위치하므로 홀수여야 합니다.


wrap : bool [since QtQuick.Controls 2.1 (Qt 5.8)]

이 속성은 텀블러가 위쪽 또는 아래쪽에 도달했을 때 텀블러를 감쌀지 여부를 결정합니다.

기본값은 countvisibleItemCount 보다 작을 때 false 이며, 이는 항목이 몇 개만 있을 때 감싸지 않는 텀블러와 상호작용하는 것이 더 간단하기 때문입니다. 이 동작을 재정의하려면 이 속성 값을 명시적으로 설정하세요. 기본 동작으로 돌아가려면 이 속성을 undefined 로 설정합니다.

이 프로퍼티는 QtQuick.Controls 2.1(Qt 5.8)에 도입되었습니다.


첨부된 속성 문서

Tumbler.displacement : real [read-only]

이 첨부 프로퍼티는 -visibleItemCount / 2 에서 visibleItemCount / 2 사이의 값을 보유하며, 이 값은 이 항목이 현재 항목에서 얼마나 멀리 떨어져 있는지를 나타냅니다( 0 은 완전히 현재 항목).

예를 들어 아래 항목은 현재 항목이 아닐 때는 40% 불투명도가 되고, 현재 항목이 되면 100% 불투명도로 전환됩니다:

delegate: Text {
    text: modelData
    opacity: 0.4 + Math.max(0, 1 - Math.abs(Tumbler.displacement)) * 0.6
}

Tumbler.tumbler : Tumbler [read-only]

이 첨부된 속성은 텀블러를 보관합니다. 이 속성은 텀블러 델리게이트에 첨부할 수 있습니다. 항목이 텀블러 델리게이트가 아닌 경우 값은 null 입니다.


메서드 문서

[since QtQuick.Controls 2.5 (Qt 5.12)] void positionViewAtIndex(int index, PositionMode mode)

indexmode 에 지정된 위치에 있도록 뷰의 위치를 지정합니다.

예를 들어

positionViewAtIndex(10, Tumbler.Center)

wrap 가 참이면(기본값) PathViewpositionViewAtIndex() 함수에서 사용할 수 있는 모드를 사용할 수 있고, 그렇지 않으면 ListViewpositionViewAtIndex() 함수에서 사용할 수 있는 모드를 사용할 수 있습니다.

참고: wraptrue 일 때 Tumbler.Beginning 을 사용하면 잘못된 항목이 보기 상단에 배치된다는 알려진 제한 사항이 있습니다. 해결 방법으로 index - 1 을 전달하세요.

이 메서드는 QtQuick.Controls 2.5(Qt 5.12)에 도입되었습니다.

currentIndex참조하십시오 .


© 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.