qt QString split
时间: 2023-10-21 10:37:28 浏览: 41
The QString split function is used to split a QString object into a list of substrings based on a separator. The syntax for the QString split function is as follows:
QStringList QString::split(const QString &separator, Qt::SplitBehavior behavior = Qt::KeepEmptyParts) const
The separator parameter specifies the character or string that is used to split the QString object into substrings. The behavior parameter specifies how the function should handle empty strings that may be generated by splitting the QString object.
The QString split function returns a QStringList object that contains the substrings generated by splitting the QString object. The substrings are stored in the list in the order in which they appear in the original QString object.
Here is an example of how the QString split function can be used to split a QString object into substrings:
QString str = "Hello, World!";
QStringList list = str.split(", ");
// The resulting list contains "Hello" and "World!" as separate strings.