qstring を 2 つの文字列に分割する必要がありますが、スプリッター文字のインデックスしか知りません。ここに例があります
input:
PineApple
3
Output:
Pine // 'e' has index 3, so it is the splitter char and it belongs to the first part
Apple
私があなたの質問を正しく理解している場合は、left
andメソッドを使用して、 :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;