C:\Users\12496\Desktop\texe\1111\2022-06-27 0851\111.txt
上面是我在一个label里面拿到的一个字符串,但是我只需要最后的111.txt 的字符串 向大家请教一下
QString 应该有lastindexof , 根据获得返回值,再substr
给你找了一篇非常好的博客,你可以看看是否有帮助,链接:QString编码转换 QString str1="C:\\Users\\12496\\Desktop\\texe\1111\\2022-06-270851\\111.txt";
int N=str1.lastIndexOf('\\') ; // 最后一个\的位置
QString str2=str1.right (str1.size()-N-1); //str2=”111.txt",提取最后一个逗号之后的字符串
qDebug()<<"str:"<<str1.size()<<"-"<<N<<str2<<endl;
可以看我的文章https://blog.csdn.net/qq_21438461/article/details/115337477