int QString::indexOf

来源:互联网 发布:python tcp 长连接 编辑:程序博客网 时间:2024/06/06 04:47

int QString::indexOf ( const QString & str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive ) const

Returns the index position of the first occurrence of the string str in this string, searching forward from index position from. Returns -1 if str is not found.

If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.

Example:

     QString x = "sticky question";     QString y = "sti";     x.indexOf(y);               // returns 0     x.indexOf(y, 1);            // returns 10     x.indexOf(y, 10);           // returns 10     x.indexOf(y, 11);           // returns -1

If from is -1, the search starts at the last character; if it is -2, at the next to last character and so on.

原创粉丝点击