Control width of Text Input in QML SpinBox
Unsolved
QML and Qt Quick
-
Hi,
I want to control the width of Text Input in QML SpinBox. We see that as we type in more characters the width of Text Input increases to accommodate the characters. We do not want this width increase but rather have the characters elided.Please help.
-
I understand you? You wonna set maximum width of TextInput with SpinBox, but field width should only grow when text gets longer?
SpinBox{ id: widthSpin } TextInput { id: textField property int textMaxWidth: widthSpin.value property int textWidth: textMetrics.width width: textWidth < textMaxWidth ? textWidth : textMaxWidth TextMetrics { id: textMetrics font: textField.font text: textField.text } }
Ofc you should add elide, max / min for widthSpin etc, property for minimum field length will be good idea too - if you set width to 0 it will look bad.