当前位置:网站首页 > 技术博客 > 正文

静态嵌套类和内部类的区别



原型

QString QString::mid(int position, int n = -1) const

Returns a string that contains n characters of this string, starting
at the specified position index. Returns a null string if the position
index exceeds the length of the string. If there are less than n
characters available in the string starting at the given position, or
if n is -1 (default), the function returns all characters that are
available from the specified position.




例子:

 
  

若需要QStringRef类型的子串,可以使用函数midRef (),与mid()类似,只是返回类型为ref,原型如下

QStringRef QString::midRef(int position, int n = -1) const

Returns a substring reference to n characters of this string, starting
at the specified position. If the position exceeds the length of the
string, a null reference is returned. If there are less than n
characters available in the string, starting at the given position, or
if n is -1 (default), the function returns all characters from the
specified position onwards.




Example:

 
  

QString 还有left() 和 right().两个函数可以取子串

原型

QString QString::left(int n) const

返回最左边n个字符的子串。当n大于等于QString.size()或n小于0的时候,返回整个字符串。

Returns a substring that contains the n leftmost characters of the
string. The entire string is returned if n is greater than or equal to
size(), or less than zero.

例子:

 
  

right()与left()类似,不阐述

版权声明


相关文章:

  • csrf攻击常见两种方法2025-10-02 23:01:04
  • c keyvaluepair2025-10-02 23:01:04
  • 乐高ev3编程软件是什么2025-10-02 23:01:04
  • c=copy.copy(a)2025-10-02 23:01:04
  • kvm虚拟化技术原理2025-10-02 23:01:04
  • 构造器的用法2025-10-02 23:01:04
  • sql简单编程2025-10-02 23:01:04
  • 接口设计6大原则2025-10-02 23:01:04
  • 调试助手全局接口地址2025-10-02 23:01:04
  • js 数组对象去重2025-10-02 23:01:04