Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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:

    0_1568398921128_problems.png



  • This is because your Text element doesn't have width property



  • @intruderexcluder WOW! I swear to god I tried that... I am a fool, thank you!


Log in to reply