我有一个文件名作为QString,它看起来像“c:/ ..... /whatIAmActuallyInterestedIn.stuff”
我想在最后/之后获得所有信息,在这种情况下,这将是whatIAmActuallyInterestedIn.stuff
现在,我知道我可以将它转换为std :: string,使用rfind查找字符串中的最后一个/,然后将其转换回QString进行输出。 但是,这看起来像是为了我相当确定的QString内置的东西做了大量的工作,我找不到函数调用。
I have a filename as a QString which looks like "c:/ ..... /whatIAmActuallyInterestedIn.stuff"
I want to get all the information after the last /, which in this case would be whatIAmActuallyInterestedIn.stuff
Right now, I know that I can convert this to a std::string, use rfind to find the last / in the string, and then convert it back to a QString for then outputting. However, this seems like doing an excessive amount of work for something that I am fairly certain QString has built in, I just can't find the function call.
最满意答案
您可以像这样提取文件名:
QFileInfo("c:/ ..... /whatIAmActuallyInterestedIn.stuff").fileName();You can extract the file name like this:
QFileInfo("c:/ ..... /whatIAmActuallyInterestedIn.stuff").fileName();更多推荐
发布评论