QString remove
时间: 2023-09-25 12:17:02 浏览: 159
remove
Sure, I can help you with that. In Qt, you can use the `remove` function of the `QString` class to remove a specific substring from a string. The syntax for using this function is as follows:
```cpp
QString str = "Hello World";
str.remove("World");
```
After executing the `remove` function, the value of `str` will be "Hello ". The `remove` function removes all occurrences of the specified substring from the original string.
Alternatively, you can also use the `replace` function to remove a part of a string by replacing it with an empty string. Here's an example:
```cpp
QString str = "Hello World";
str.replace("World", "");
```
In this case, the value of `str` will also be "Hello ". The `replace` function replaces all occurrences of the specified substring with the replacement string, which is an empty string in this case.
I hope this helps! Let me know if you have any further questions.
阅读全文