int QString::size () const

来源:互联网 发布:网络空间面临的风险有 编辑:程序博客网 时间:2024/06/06 04:00

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'

原创粉丝点击