Limit the number of input characters in TextArea
Solved
QML and Qt Quick
-
There is nothing built-in, but you can implement the limit with something like this:
TextArea { onTextChanged: if (length > MyLimit) remove(MyLimit, length); }
-
:-) you're welcome, happy coding!
-
-
I think this is better:
property int maximumLength: -1; property string lastValidText: ""; onTextChanged: { if (text.length > maximumLength && maximumLength>-1) { var currentPosition = cursorPosition-1; text = lastValidText; cursorPosition = currentPosition; } else { lastValidText = text; } }