Tumbler QML Type

A control that can have several spinnable wheels, each with items that can be selected. 更多...

导入语句: import QtQuick.Extras 1.4
Since: Qt 5.5
继承:

FocusScope

特性

方法

详细描述

A Tumbler

注意: Tumbler requires Qt 5.5.0 or later.

The Tumbler control is used with one or more TumblerColumn items, which define the content of each column:

Tumbler {
    TumblerColumn {
        model: 5
    }
    TumblerColumn {
        model: [0, 1, 2, 3, 4]
    }
    TumblerColumn {
        model: ["A", "B", "C", "D", "E"]
    }
}
					

You can also use a traditional model with roles:

Rectangle {
    width: 220
    height: 350
    color: "#494d53"
    ListModel {
        id: listModel
        ListElement {
            foo: "A"
            bar: "B"
            baz: "C"
        }
        ListElement {
            foo: "A"
            bar: "B"
            baz: "C"
        }
        ListElement {
            foo: "A"
            bar: "B"
            baz: "C"
        }
    }
    Tumbler {
        anchors.centerIn: parent
        TumblerColumn {
            model: listModel
            role: "foo"
        }
        TumblerColumn {
            model: listModel
            role: "bar"
        }
        TumblerColumn {
            model: listModel
            role: "baz"
        }
    }
}
					

局限性

For technical reasons, the model count must be equal to or greater than visibleItemCount plus one. The visibleItemCount must also be an odd number.

You can create a custom appearance for a Tumbler by assigning a TumblerStyle . To style individual columns, use the delegate and highlight properties of TumblerColumn .

特性文档编制

[read-only] columnCount : int

The number of columns in the Tumbler.


style : 组件

The style Component for this control.

另请参阅 Qt Quick Controls Styles QML Types .


方法文档编制

TumblerColumn addColumn ( TumblerColumn column )

Adds a column and returns the added column.

column argument can be an instance of TumblerColumn ,或 组件 . The component has to contain a TumblerColumn . Otherwise null 被返回。


int currentIndexAt ( int columnIndex )

Returns the current index of the column at columnIndex ,或 null index 无效。


TumblerColumn getColumn ( int columnIndex )

Returns the column at columnIndex or null if the index is invalid.


TumblerColumn insertColumn ( int index , TumblerColumn column )

插入 column 在给定 index and returns the inserted column.

column argument can be an instance of TumblerColumn ,或 组件 . The component has to contain a TumblerColumn 。否则, null 被返回。


void setCurrentIndexAt ( int columnIndex , int itemIndex , int interval )

Sets the current index of the column at columnIndex to itemIndex . The animation length can be set with interval ,其默认为 0 .

什么都不做若 columnIndex or itemIndex are invalid.