SpinBox with percentage symbol
Solved
QML and Qt Quick
-
@Ahti
by reimplementingtextFromValue
andvalueFromText
On how to do that, there's a very well and detailed example in the documentary:
https://doc.qt.io/qt-5/qml-qtquick-controls2-spinbox.html#custom-values
It is for making a doublespinbox, but you should be able to adapt that to a prefix only :)
-
Hi @Ahti , if you trying to customize the contentItem of the Spinbox then i guess you can also use the contentItem property and add "%" to the Text.
Sample Code:-
SpinBox { id: control value: 20 contentItem: Text { z: 2 text: control.value + "%" font: control.font color: "green" horizontalAlignment: Qt.AlignHCenter verticalAlignment: Qt.AlignVCenter } }
Sample Output:-