Find and store each uppercase letter in button text
Solved
General and Desktop
-
- 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() ) { } }
-
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); }
-
- 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() ) { } }
@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.
-
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); }
-
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); }