
Originally Posted by
aurora
Is there any standard function(or way) to get the first letter of a given string?
std::cout << s.at(0); << std::endl; // prints 'a'
QString s("are you a troll?");
std::cout << s.at(0); << std::endl; // prints 'a'
To copy to clipboard, switch view to plain text mode

If however you want the first word, as the comment in your code snippet suggest, you could try this :
QString("read the docs luke").split(QRegExp("\\W+"), QString::SkipEmptyParts).at(0);
To copy to clipboard, switch view to plain text mode
Bookmarks