Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QString character erase function

Tags:

c++

qt

qstring

QString line = "example string";

Now I want to erase the space between 'example' and 'string' so that I get a string like this "examplestring". Is there a function in Qt which erases a character under the given index or should I write this function myself ?

like image 570
samvel1024 Avatar asked Oct 18 '13 07:10

samvel1024


2 Answers

What about QString::remove(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) function? You can use ' ' as a first argument. I.e.:

QString line = "example string";
line.remove(' ');
like image 108
vahancho Avatar answered Nov 13 '22 17:11

vahancho


line = line.remove(index,1);

see the documentation

like image 32
ratchet freak Avatar answered Nov 13 '22 19:11

ratchet freak