[Qt-qml] QML and binding loop problem
Valentine Silvansky
v.silvansky at gmail.com
Tue Nov 16 14:43:53 CET 2010
Hi all! I've got some problem...
I have to make a elide for multiline text. Here is the code I wrote:
<pre>
Text {
id: tempText
visible: false
width: parent.width
wrapMode: Text.WordWrap
function elideMultiline(etext, pointSize, linesCount) {
console.log("elideMultiline: " + etext + " " + pointSize + " " + linesCount)
tempText.font.pointSize = pointSize
var l = etext.length
var s = "";
for (var i = 0; i < linesCount; i++) {
s += "W";
if (i < linesCount - 1)
s += "\n"
}
tempText.text = s
console.log("s = " + s)
var maxHeight = tempText.paintedHeight
tempText.text = etext
while (tempText.paintedHeight > maxHeight) {
tempText.text = etext.substring(0, l--) + "..."
}
return tempText.text
}
}
Text {
id: longText
width: parent.width
wrapMode: Text.WordWrap
font.pointSize: 16
text: tempText.elideMultiline("my very-very-very-very and very long
text with a lot of words in it and which i want to be correctly
elided", font.pointSize, 2)
}</pre>
And when running my qml I've got this output:
QML Text: Binding loop detected for property "text"
The resulting qml output is ok, function works as expected, but i've
got tons of console output messages...
What's the problem of this code?
PS: if I use Component.onCompleted: { text = "....." } no messages are printed
More information about the Qt-qml
mailing list