Let me know on what units the TextMetrics width is display [pixel/point or some other ..] Below is the snippet of my code and output of the same.
TextMetrics
{
id:textMetrics
text: ''
}
onPopupItemsChanged; {
var lowerCase = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
console.log("Lower Case")
for(var k = 0; k < lowerCase.length; k++) {
textMetrics.text = lowerCase[k];
console.log(textMetrics.text, textMetrics.width)
}
}
Output:
qml: Lower Case
qml: a 7
qml: b 8
qml: c 7
qml: d 8
qml: e 8
qml: f 5
qml: g 8
qml: h 7
qml: i 3
qml: j 5
qml: k 7
qml: l 3
qml: m 11
qml: n 7
qml: o 9
qml: p 8
qml: q 8
qml: r 5
qml: s 7
qml: t 5
qml: u 7
qml: v 8
qml: w 12
qml: x 8
qml: y 8
qml: z 7
width() simply returns boundingRect().width() which is in pixels: