Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[solved. thank you!] upper case
how do you know if a word (QString) begins with an upper case letter and how to make this first letter to be upper?
vsorokin last edited by
via Qt Centre forum (I not checked this)
@QString capitalize(const QString &str)
QString tmp = str;
// if you want to ensure all other letters are lowercase:
tmp = tmp.toLower();
tmp = str.toUpper();
Actually that code is not correct since Unicode does have funny little chars like "01C9;LATIN SMALL LETTER LJ". That is one lowercase letter (lj).
Uppercasing that gives you "01C7;LATIN CAPITAL LETTER LJ" (LJ).
So that is not what you want.
You want "01C8;LATIN CAPITAL LETTER L WITH SMALL LETTER J" (Lj), which is the Titlecase. So you should use toTitleCase() instead of toUpper().
i solved with
QString parola = "ciao";
parola.replace(0, 1, parola.toUpper());
QString parola = QLatin1String("ciao");
parola = parola.at(0).toTitleCase();