문제

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 ?

도움이 되었습니까?

해결책 2

line = line.remove(index,1);

see the documentation

다른 팁

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(' ');

You can use

line.replace(QString(" "), QString(""));
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top