Howto substring using QString
Solved
General and Desktop
-
I'm used to std::string so doesn't really know much about QString class.
How can i substring on QString, I will give you my scenerio.
lets say i've a path i.e. path\to\file.jpg
In order to extract the filename from the above path, i usually substring using std::string::substr(..) like below:
std::string path {"path\\to\\file.jpg"}; std::string filename = path.substr(path.find_last_of("\\")+1); // file.jpg
How would i do this in QString ?
-
@pingal said in Howto substring using QString:
How would i do this in QString ?
By taking a look in the documentation: QString::mid(), QString::indexOf()