问题
I just wanted to know what the technical term for allocating words from a string separated by spaces to a variable is called so I can look up a tutorial for it. Any terms, links, or explanations would be greatly appreciated.
回答1:
You can do it like:
QString lineText = "some sample words";
QStringList tokens= lineText.split(" ",QString::SkipEmptyParts);
You can do whatever you like with the words in the tokens list.
来源:https://stackoverflow.com/questions/21367276/allocating-words-from-a-string-separated-by-spaces-to-a-variable-c-qt