Solved elide not working
-
Here I have a simple rectangle which will contain a string entered by the user. If the string does not fit within the width of the rectangle I would like to show the ellipse. However, elide is not working like I thought it would, is there something I have missed?
Rectangle { id: display color: "white" height: componentHeight width: componentWidth radius: 5 TextStyled { id: textEntryDisplay elide: Text.ElideRight style: fontStyle anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: display.bottom color: modelData.settingInvalid ? "red" : "gray" Component.onCompleted: { if(modelData.settingInvalid) { textEntryDisplay.text = modelData.value value_container.allowNext = false } else { textEntryDisplay.text = modelData.value } } } }
Here is TextStyled.qml:
Text { id: control property BaseTextStyle style: Style1TextStyle {} font: control.style.font color: control.style.color }
-
@circuits said in elide not working:
However, elide is not working like I thought it would,
Please provide some output showing what happening...
-
Sure no problem:
-
This is because your
Text
element doesn't havewidth
property -
@intruderexcluder WOW! I swear to god I tried that... I am a fool, thank you!