Solved Correct way to select/replace all text of a TextField if it gains focus?
-
Hello,
I have a TextField in QML and I would like to be able to immediately replace the old text with a new text by entering the field and typing without deleting the old text manually.
Therefore, I would like to automatically select all old text whenever the field has the focus.
Also, it would be good, that if no new text is typed the old text stays.
How do I do that?Thank you very much :-)
-
hi @robro
the selectAll methos should be all you need:
http://doc.qt.io/qt-5/qml-qtquick-controls-textfield.html#selectAll-methodpossible usage:
TextField{ .... onFocusChanged:{ if(focus) selectAll() } }
-
Thank you! :-)