Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Find and store each uppercase letter in button text
Forum Updated to NodeBB v4.3 + New Features

Find and store each uppercase letter in button text

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 246 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.
  • K Offline
    K Offline
    Kris Revi
    wrote on last edited by
    #1
    • how can i get each uppercase letter (so grab the current text from the button)
    • from each button text in a container (so a list of buttons)
    • and set that as the text on the button? (store each uppercase letter in a new QString and set that as the text on the button)

    something like this?

            for (QPushButton * pButton : _patternButtonList)
            {
                if ( pButton->text().isUpper() )
                {
                }
            }
    
    sierdzioS 1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by sierdzio
      #3

      I'm not sure if you want to rename each button with it's uppercase letters or rename one button with uppercase letters from all other buttons.

      Assuming the former:

      for (auto button : qAsConst(_patternButtonList))
        {
          QString upperCaseLetters;
          for (const QChar &character : button->text()) {
            if ( character.isUpper()) {
              upperCaseLetters.append(character);
            }
          }
          button->setText(upperCaseLetters);
        }
      

      (Z(:^

      K 1 Reply Last reply
      2
      • K Kris Revi
        • how can i get each uppercase letter (so grab the current text from the button)
        • from each button text in a container (so a list of buttons)
        • and set that as the text on the button? (store each uppercase letter in a new QString and set that as the text on the button)

        something like this?

                for (QPushButton * pButton : _patternButtonList)
                {
                    if ( pButton->text().isUpper() )
                    {
                    }
                }
        
        sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #2

        @Kris-Revi said in Find and store each uppercase letter in button text:

        • how can i get each uppercase letter (so grab the current text from the button)
        • from each button text in a container (so a list of buttons)
        • and set that as the text on the button? (store each uppercase letter in a new QString and set that as the text on the button)

        something like this?

                for (QPushButton * pButton : _patternButtonList)
                {
                    if ( pButton->text().isUpper() )
                    {
                    }
                }
        

        Yes.

        (Z(:^

        1 Reply Last reply
        1
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by sierdzio
          #3

          I'm not sure if you want to rename each button with it's uppercase letters or rename one button with uppercase letters from all other buttons.

          Assuming the former:

          for (auto button : qAsConst(_patternButtonList))
            {
              QString upperCaseLetters;
              for (const QChar &character : button->text()) {
                if ( character.isUpper()) {
                  upperCaseLetters.append(character);
                }
              }
              button->setText(upperCaseLetters);
            }
          

          (Z(:^

          K 1 Reply Last reply
          2
          • sierdzioS sierdzio

            I'm not sure if you want to rename each button with it's uppercase letters or rename one button with uppercase letters from all other buttons.

            Assuming the former:

            for (auto button : qAsConst(_patternButtonList))
              {
                QString upperCaseLetters;
                for (const QChar &character : button->text()) {
                  if ( character.isUpper()) {
                    upperCaseLetters.append(character);
                  }
                }
                button->setText(upperCaseLetters);
              }
            
            K Offline
            K Offline
            Kris Revi
            wrote on last edited by
            #4

            @sierdzio damn exactly what i was trying todo! :) thank you so much for that :)

            1 Reply Last reply
            1

            • Login

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