我需要将一个qstring拆分为两个字符串,但只知道拆分器字符的索引。下面是一个例子
input:
PineApple
3
Output:
Pine // 'e' has index 3, so it is the splitter char and it belongs to the first part
Apple发布于 2012-12-03 05:37:06
如果我正确理解了您的问题,您可以使用left和mid方法来提取offset之前和之后的字符串部分
quint32 offset = 4;
QString test("PineApple");
QString before = test.left(offset); // Pine
QString after = test.mid(offset); // Apple如果你想要得到一个QStringList (如果你使用了split),你可以像这样获得一个:
QStringList list;
list << before
<< after;https://stackoverflow.com/questions/13674057
复制相似问题