Replacing a character in a QLineEdit text
General and Desktop
6
Posts
2
Posters
2.5k
Views
1
Watching
-
Hi,
To simplify, I am using a QlineEdit line that contains : PRTU
I would like to replace the character 'R' by ' S'.
I tried :
line.text().replace('R','S') But it seems not to work.
I tried also:
text=""
if(line.text().contains('P') text=text+"P";
if (line.text().contains('R') text=text+"S"
if(line.text().contains('T') text=text+"T";
if(line.text().contains('U') text=text+"U";
line.setText(text);
but with no avail.
Could you help me, please -
@
QString text = line.text();
text.replace("R", "S");
line.setText(text);
@That should work.
-
I don't know. Code looks ok.
-
No problem, we all make mistakes in our apps :)