我想达到与
std::string s = "abc";
s[1]++;
但是有一个QString
,但是Qt不允许我这样做:
QString s = "abc";
s[1]++;
之后我收到编译错误。
> QString::operator[]
返回没有operator++
的QCharRef
。
您可以通过执行以下操作来解决此问题:
s[1] = s[1].toAscii() + 1;
通过使用
:text[i] = text[i].unicode() + 1;
感谢您的帮助
您也可以使用at()
方法进行QString
它的工作原理如下:
QString str = "abc";
QChar myChar = str.at(1) + 1
您可以在此链接中看到QString
操作