我试图给出Tumbler
我自己的风格。我这样声明Tumbler
:
Tumbler {
style: MyTumblerStyle {}
height: UIConstants.smallFontSize * 10
width: UIConstants.smallFontSize * 3
TumblerColumn {
model: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]
}
}
whereMyTymblerStyle
定义如下:
TumblerStyle {
id: root
visibleItemCount: 5
background: Rectangle {}
foreground: Item {}
frame: Item {}
highlight: Item {}
delegate: Item {
id: delRoot
implicitHeight: (control.height) / root.visibleItemCount
Item {
anchors.fill: parent
Text {
text: styleData.value
font.pixelSize: UIConstants.smallFontSize
font.family: UIConstants.robotoregular
anchors.centerIn: parent
scale: 1.0 + Math.max(0, 1 - Math.abs(styleData.displacement)) * 0.6
color: styleData.current?UIConstants.color:"black"
opacity: 1 - Math.abs(styleData.displacement/(root.visibleItemCount-3))
}
}
}
}
我Row
像这样使用它:
Row {
MyTumbler {}
StandardText {
color: UIConstants.color
text: "Uhr"
}
}
现在,结果如下所示:
如您所见,"Uhr"
文本中心与Tumbler
. 也Row
好像不认真本width
了Tumbler
。
为什么?当我不使用它时它确实有效MyTumblerStyle
。