Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [solved. thank you!] upper case

[solved. thank you!] upper case

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 3 Posters 22.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    spode
    wrote on last edited by
    #1

    how do you know if a word (QString) begins with an upper case letter and how to make this first letter to be upper?

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vsorokin
      wrote on last edited by
      #2

      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[0] = str[0].toUpper();
      return tmp;
      }@

      --
      Vasiliy

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tobias.hunger
        wrote on last edited by
        #3

        <nitpick>
        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().
        </nitpick>

        1 Reply Last reply
        0
        • S Offline
          S Offline
          spode
          wrote on last edited by
          #4

          i solved with
          @
          QString parola = "ciao";
          parola.replace(0, 1, parola[0].toUpper());
          //returns Ciao
          @

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tobias.hunger
            wrote on last edited by
            #5

            @
            QString parola = QLatin1String("ciao");
            parola[0] = parola.at(0).toTitleCase();
            @

            1 Reply Last reply
            1
            • S Offline
              S Offline
              spode
              wrote on last edited by
              #6

              right! ;)

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved