First, it should be in LineEdit. It should react to actual right margin set in LineEdit rather than actual screen width. And IMO it should work only while entering text (means, as part of character input handler) (not 100% sure about this last one .
And non-WString variant is useless. Just convert to WString and do the same, no?