[Interest] QML Text.contentWidth is never increasing
Jason H
jhihn at gmx.com
Thu Oct 20 23:08:14 CEST 2016
http://doc.qt.io/qt-5/qml-qtquick-text.html#contentWidth-prop
"Returns the width of the text, including width past the width which is covered due to insufficient wrapping if WrapMode is set."
However if it ever enters into a wrapping situtation, it becomes the wrapped width:
|A B C| (decreasing width)
|A B|
|C |
|A|
|B|
|C|
Once at that level, if space is then supplied it stays:
|A |
|B |
|C |
Rather than
|A B|
|C |
|A B C|
Is there a way to work around this?
I often use it like:
Text {
id: instructionText
color: "white"
text: instructionTextData
width: contentWidth > parent.width *.9 ? parent.width *.9 : contentWidth
font.pointSize: 16
horizontalAlignment: Text.AlignHCenter
anchors.horizontalCenter: parent.horizontalCenter
}
Where I want the text to be it's natural width up to 90% of the parent width, then wrap, but it only works when initially laying out and shrinking.
More information about the Interest
mailing list