01-31-2013 03:55 PM
I need to select(highlight) existing text that is present in TextArea based on users choice i.e SystemPrompt is shown where user enters desired text and if that text is currently present in TextArea, highlight it, otherwise display additional info. Something like Find function in standard notepad application.
I can't find what I'm looking for in TextEditor.
Solved! Go to Solution.
02-01-2013 02:32 PM
02-01-2013 02:44 PM
TextArea's text can be accessed using text property.
If you can access the text typed by user then the indexes can be easily calculated. Something like this (untested):
QString textAreaText = textArea->text(); QString userInput = ...; int startIndex = textAreaText.indexOf(userInput, 0, Qt::CaseInsensitive); int endIndex = startIndex + userInput.length();
02-01-2013 03:21 PM
ATM the only reasonable solution (not the perfect one), but it works.
In QML if somebody needs it
var start = textArea.text.indexOf(inputFieldTextEntry()) var end = start + inputFieldTextEntry().length textArea.editor.setSelection(start,end)