PDA

View Full Version : QSting replace not working



raphaelf
24th October 2006, 11:30
Hi everybody.

QT 4.1.3 Win MINGW

I am trying to replace "'"with "\'" but its not working :crying:

Have somebody a idea why not?

Don't musst be Don\'t after replacing


//style = Don't
QString style = ui.add_new_style_le->text();
QString test = style.replace(QString("'"), QString("\'"));
//test = Don't and not Don\'t :crying:
QMessageBox::information(this,"",test);

jpn
24th October 2006, 11:37
"\" is an escape character and must be escaped itself it not used as an escape char:

str.replace("'", "\\'");

raphaelf
24th October 2006, 12:08
Hi jpn`:p

thanks it works!!