int QString::size () const
Returns the number of characters in this string.
The last character in the string is at position size() - 1. In addition, QString ensures that the character at position size() is always '/0', so that you can use the return value of data() and constData() as arguments to functions that expect '/0'-terminated strings.
Example:
QString str = "World";
int n = str.size(); // n == 5
str.data()[0]; // returns 'W'
str.data()[4]; // returns 'd'
str.data()[5]; // returns '/0'
本文详细介绍了QString中的size()方法,该方法返回字符串中字符的数量。文章通过实例展示了如何使用此方法获取字符串长度,并解释了size()返回值在使用data()和constData()作为'/0'-终止字符串参数时的应用。
377

被折叠的 条评论
为什么被折叠?



