A mouse up/down can be used in the following code to increment/dec the text value when the cursor is over top the item. What is the best way to make the scroll wheel do the same? Note, I need this for many items on a single screen. With a QDeclarativeItem subclass, would I need to implement the below in C++?
With the "implement in mainWindow and sync with qml", would this approach work and how does it look from a high level?
I'm still climbing the QML learning curve, so so looking for a high level overview or a place to start.
Thanks,
Cliff
@
Rectangle {
id: valuebox
smooth: true
anchors.margins: 10
radius: 10
property color default_color: "white"
color: default_color
property alias text: text.text
property alias text_color: text.color
property int default_pixel_size
Text {
id: text
anchors.centerIn: parent; anchors.verticalCenterOffset: -1
font.pixelSize: parent.width > parent.height ? parent.height * .5 : parent.width * .5
color: "white"
style: Text.Sunken
styleColor: "black"
smooth: true
}
Keys.onUpPressed: {
text.text = text.text - (-1)
}
Keys.onDownPressed: {
text.text = text.text - 1
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: {
default_pixel_size = text.font.pixelSize
text.font.pixelSize = default_pixel_size + 5
parent.color = "yellow"
valuebox.focus = true
}
onExited: {
text.font.pixelSize = default_pixel_size
parent.color = default_color
valuebox.focus = false
}
}
}
@