i did play around a while ago with capitalization on an Label.
the result was not great, not what i would expect.
i would like to have just two options:
- no capitalization
- mixed cap, so first char
but i wanted to have that just during user input
the current result now is: even lower case input is capitalized on load when i use the mixed …
does anybody know the propper setting for that ?
or do i need to set that manually only in edit mode, that would feel strange imho
You could try disabling signals, setting the text and enabling signals, but I’m not sure if it affects rendering too…
I wish I could remember why, but in my Location based lookup of weather stations I employed a javascript hack to get Labels into mixed case.
delegate: ListItem {
Label {
text: titleCase(model.station_name) + " - " + model.distance + qsTr(" meters")
truncationMode: TruncationMode.Fade
}
function titleCase(str) {
str = str.toLowerCase();
var words = str.split(' ');
var results = [];
for (var i = 0; i < words.length; i++) {
var letter = words[i].charAt(0).toUpperCase();
results.push(letter + words[i].slice(1));
}
return results.join(' ');
}
I just have no idea now, why!
Something similar to poetaster’s answer;
Label {
id: wait
text: {
var wait = "waiting for GPS"
return wait[0].toUpperCase() + wait.substring(1)
}
}
Something like this would let you process the text more freely:
Label {
id: thatLabel
property initialText: ''
onInitialTextChanged: {
var newText = initialText
// Manipulate newText as needed
text = newText
}
}
And then update thatLabel.initialText
instead of thatLabel.text