Problem with custom TextBox
-
Hello,
I've made a TextBox that can be flicked and it works fine except for one small issue that I don't know how to resolve. Whenever I try to increase the width of the window, the text's width won't follow, but it will update as soon as I decrease the width of the window even if I've increased the width before that.Here's the code:
TextBox.qml
@import QtQuick 2.0
Rectangle {
id: textBox
width: 500
height: 300
color: "#1a4381"
border.color: "#ffffff"
clip: trueproperty alias text: boxText.text property alias fontPixelSize: boxText.font.pixelSize property alias fontFamily: boxText.font.family Flickable { id: textFlick contentWidth: parent.width contentHeight: boxText.height clip: true flickableDirection: Flickable.VerticalFlick anchors.fill: parent Text { id: boxText height: paintedHeight+4 text: "" font.pixelSize: 16 font.family: "Arial" color: "#ffffff" wrapMode: Text.WordWrap anchors.left: parent.left anchors.leftMargin: 2 anchors.right: parent.right anchors.rightMargin: 2 textFormat: Text.RichText } }
}
@And a sample main.qml:
@import QtQuick 2.0
Rectangle
{
width: 200
height: 200
color: "grey"TextBox { anchors.fill: parent text: "aaaaaaa aaaaaaaaa aaaaaaaaaaaaa aaaaaaaaaaaaaa aaaaaaa" }
}@